You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The ORDER BY present in the end of a UNION query should be associated with the UNION query as a whole. Currently, it is being associated with the last SELECT query in the UNION.
To Reproduce
Steps to reproduce the behavior:
Example SQL
SELECT*FROM table1 UNIONSELECT*FROM table2 ORDER BY col
Parsing this SQL using JSqlParser with this statements
SelectunionQuery = (Select) CCJSqlParserUtil.parse("SELECT * FROM table1 UNION SELECT * FROM table2 ORDER BY col");
SetOperationListunionQueries = (SetOperationList) unionQuery.getSelectBody();
System.out.println(unionQueries.getOrderByElements());
unionQueries.getSelects().forEach(query -> {
PlainSelectplainQuery = (PlainSelect) query;
System.out.println(plainQuery.getOrderByElements());
});
Actual Output:
null
null
[col]
Expected behavior
The expected output is as follows:
Describe the bug
The ORDER BY present in the end of a UNION query should be associated with the UNION query as a whole. Currently, it is being associated with the last SELECT query in the UNION.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The expected output is as follows:
Ref
System
The text was updated successfully, but these errors were encountered: