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

suggestion: Force rownum (Oracle dialect) to be a number with the function to_number() #6021

Open
S200124 opened this issue Mar 4, 2024 · 0 comments · May be fixed by #6026
Open

suggestion: Force rownum (Oracle dialect) to be a number with the function to_number() #6021

S200124 opened this issue Mar 4, 2024 · 0 comments · May be fixed by #6026

Comments

@S200124
Copy link

S200124 commented Mar 4, 2024

Knex version: 3.1.0
Database + version: Oracle 19c EE
OS: Red Hat Enterprise Linux Server 7.9

Suggestion/improvement to cover Oracle bug (?)

When building a query using the limit() function, in Oracle it is translate to the clause "where rownum <= ?" (which is correct). But sometimes, inconsistently and for unknown reasons, Oracle raises the error "ORA-01722: invalid number".
This can be solved forcing rownum to be a number -> "where to_number(rownum) <= ?"

Error message:
Error: select * from (select "COL1", "COL2", "COL3", "COL4", "COL5", "COL6" from "TABLE" order by "COL3" ASC) where rownum <= :1 - ORA-01722: invalid number

This is not a Knex bug, and for what I can see, it is not a consistent error in Oracle. I use the same limit() function with the same setup on other tables/query, and it works without problem. However, changing "where rownum <= ?" to "where to_number(rownum) <= ?" should cover all cases, also the special ones.

@atiertant

@S200124 S200124 linked a pull request Mar 7, 2024 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.

1 participant