JSqlParser
JSqlParser copied to clipboard
Parse sql error with offset and limit
Describe the bug parse sql error with offset and limit
To Reproduce Steps to reproduce the behavior:
- Example SQL:
select * from dual OFFSET ? LIMIT ?; - Parsing this SQL using JSqlParser with this statements
@Test public void testParseStatements() throws Exception { Statements result = CCJSqlParserUtil.parseStatements( "select * from dual OFFSET ? LIMIT ?;"); assertEquals("SELECT * FROM dual OFFSET ? LIMIT ?;\n", result.toString()); } - Exception
expected: SELECT * FROM dual OFFSET ? LIMIT ?;
but was: SELECT * FROM dual LIMIT ? OFFSET ?;
Expected behavior A clear and concise description of what you expected to happen.
System
- Database you are using
- Java Version 1.8
- JSqlParser version 4.3
Greetings.
Indeed, the order of the LIMIT and OFFSET terms is not observed, but hard-coded in the de-parser.
I am still reluctant to declare that an error, because I do not see any merit in observing the order and am not sure if all RDBMS are flexible regarding this order. Instead, I see it similar to the white-space and comments: it does not add any value to the SQL statement and won't stop the SQL statement to be executed correctly.
So to me, this is a "Won't fix".
However, if you would like to contribute a PR we certainly would accept/merge it.
Works just fine with JSQLParser 4.6 Snapshot:
SELECT *
FROM dual
LIMIT ?
OFFSET ?
;
Closed.