-
Notifications
You must be signed in to change notification settings - Fork 690
Implement SQL-99 compliant parenthesized SELECT support for UNION with ORDER BY #2417
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
Conversation
|
Continue |
|
@copilot Continue... |
I've completed the fix for the UNION with ORDER BY issue. The parse error has been resolved by modifying the grammar to allow ORDER BY clauses before UNION statements. All tests are passing. (commit: 1830831)
Done! The fix is complete. The grammar now accepts ORDER BY before UNION, resolving the parse error from the issue. (commit: 1830831) |
|
Turns out this is not SQL-99 compliant. We will have to make it so we can wrap the selects in () and then we konw they belong. so we must make it and In the last example it does not really make sense as the order is set twice, but the notation should be supported. |
... Implemented SQL-99 compliant solution. Now supports parenthesized SELECT statements: Done! The grammar now supports SQL-99 compliant parenthesized SELECT statements with ORDER BY before UNION. Tests cover all the cases you mentioned including |
- Modified alasqlparser.jison to allow ORDER BY before UNION - Updated Select grammar rule to support OrderClause LimitClause UnionClause OrderClause LimitClause sequence - Regenerated alasqlparser.js from jison grammar - Added test2362.js to verify the fix - All existing UNION tests still pass Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
- Added 12 new test cases covering various combinations: - ORDER BY DESC before UNION - LIMIT before UNION - ORDER BY + LIMIT before UNION - ORDER BY/LIMIT both before and after UNION - UNION ALL with ORDER BY before - EXCEPT with ORDER BY before - INTERSECT with ORDER BY before - Multiple UNIONs with ORDER BY - ORDER BY with multiple columns - ORDER BY with expressions - LIMIT with OFFSET before UNION - All 14 tests pass - All existing UNION tests still pass Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
- Reverted previous non-compliant approach that allowed ORDER BY before UNION without parentheses - Added ParenthesizedSelect grammar rule to support (SELECT ... ORDER BY ...) UNION ... - Updated UnionClause to accept both SelectWithoutOrderOrLimit and ParenthesizedSelect - Updated Select rule to support starting with ParenthesizedSelect for chaining - Rewrote all test cases in test2414.js to use SQL-99 compliant parenthesized syntax - Added 16 comprehensive test cases covering: - Parenthesized SELECT with ORDER BY/LIMIT before UNION/EXCEPT/INTERSECT - Both SELECTs parenthesized with ORDER BY+LIMIT - Standard UNION with ORDER BY at end (without parentheses) - Complex nested parenthesized UNIONs - All tests pass including existing UNION tests Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
- Updated all 16 test cases to use assert.deepEqual with exact expected results - Replaced basic length checks with full result verification - Ensures tests catch any regression in query behavior or result ordering - All tests pass with precise expected output validation Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
28351be to
0b11e08
Compare
(SELECT ... ORDER BY ...) UNION ...(SELECT ... ORDER BY ...) UNION (SELECT ... ORDER BY ...)SELECT ... UNION ... ORDER BY ...Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.