Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PetaPoco. Providers: When using Oracle, calling FetchAsync will throw exception #691

Open
jackzhang520 opened this issue Sep 16, 2023 · 5 comments · Fixed by #707
Open

Comments

@jackzhang520
Copy link

jackzhang520 commented Sep 16, 2023

PetaPoco. Providers: When using Oracle, calling FetchAsync will thow exception
SQL will start with "SELECT * FROM (SELECT ROW-NUMBER() OVER (ORDER BY (SELECT NULL)) peta_ Rn", but in ORACLE, "SELECT NULL" will prompt ORA-00923: The required FROM keyword was not found. After reading PetaPoco's source code, the BuildPageQuery of OracleDatabaseProvider will be redirected to the BuildPageQuery of SqlServerDatabaseProvider, causing this issue.

Change "SELECT NULL" to " SELECT NULL from DUAL" can fix this issue

@jackzhang520 jackzhang520 changed the title PetaPoco. Providers: When using Oracle, calling FetchAsync will result in an exception PetaPoco. Providers: When using Oracle, calling FetchAsync will response an exception Sep 16, 2023
@jackzhang520 jackzhang520 changed the title PetaPoco. Providers: When using Oracle, calling FetchAsync will response an exception PetaPoco. Providers: When using Oracle, calling FetchAsync will throw exception Sep 18, 2023
@Ste1io
Copy link
Collaborator

Ste1io commented Sep 20, 2023

@jackzhang520 is there a specific test that fails from this? I'm currently updating the docker configuration for the test projects, and can look into this once that's done.

@jackzhang520
Copy link
Author

jackzhang520 commented Sep 20, 2023

@Ste1io To solve this problem, it is necessary to modify PetaPoco.Providers.OracleDatabaseProvider like this:

image

@Ste1io Ste1io mentioned this issue Sep 20, 2023
18 tasks
@jackzhang520
Copy link
Author

jackzhang520 commented Sep 23, 2023

Please test by
Dababase: Oracle
Method: PetaPoco.IQueryAsync.PageAsync
SqlOrderBy=null
image

@Ste1io
Copy link
Collaborator

Ste1io commented Sep 24, 2023

Testing anything for Oracle will have to wait until I complete #697 and merge it into the Development branch. It looks like you have already found a fix for this issue, based on your screenshots. Could you open a PR with your changes, so we have something ready once Oracle tests are added?

@jackzhang520
Copy link
Author

jackzhang520 commented Oct 9, 2023

@Ste1io
Oracle中不能直接将SELECT NULL作为SQL输出NULL,需要使用SELECT NULL FROM DUAL,这是它与其它数据库不同的地方。
In Oracle, SELECT NULL cannot be directly used as SQL output NULL. Instead, SELECT NULL from DUAL needs to be used, which is different from other databases.

image
image

see https://www.databasestar.com/dual-table-in-oracle/
The DUAL table is a one row, one column, dummy table used by Oracle.
SELECT statements need a table, and if you don’t need one for your query, you can use the DUAL table
Don’t modify or delete the DUAL table.

Ste1io added a commit that referenced this issue Oct 23, 2023
Fix some more failing integration tests

Fixes #691 
Fixes #255
@Ste1io Ste1io linked a pull request Oct 23, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants