Repository navigation
Fix ORDER BY clause handling in multiple UNIONs - #2188
Merged
Merged
Conversation
- Modified alasqlparser.jison to create SelectWithoutOrderOrLimit rule - Updated UnionClause to reference SelectWithoutOrderOrLimit - Fixed 40select.js to not override top-level orderfn from union clauses - Added orderColumns to query object for union handling - Added logic in 38query.js to populate order keys before sorting for union queries - Enabled test7.js tests Co-authored-by: mathiasrw <[email protected]>
Co-authored-by: mathiasrw <[email protected]>
Copilot stopped work on behalf of
mathiasrw due to an error
November 19, 2025 10:30
mathiasrw
requested changes
Nov 19, 2025
Member
|
Run yarn test-format-all |
- Added 7 new test cases (G-M) covering plain UNION, INTERSECT, EXCEPT, and edge cases - Fixed code formatting in src/38query.js and src/424select.js using prettier - All 13 test cases in test7.js now pass Co-authored-by: mathiasrw <[email protected]>
Contributor
Author
Copilot
AI
changed the title
[WIP] Fix ORDER BY clause handling in multiple UNIONs
Fix ORDER BY clause handling in multiple UNIONs
Nov 19, 2025
Member
|
@copilot Please run |
mathiasrw
marked this pull request as ready for review
November 19, 2025 13:02
Ran `yarn jison` to regenerate src/alasqlparser.js from the grammar file. All tests continue to pass. Co-authored-by: mathiasrw <[email protected]>
Contributor
Author
mathiasrw
approved these changes
Nov 19, 2025
mathiasrw
requested changes
Nov 19, 2025
Member
|
@copilot Did you see the comments? |
Added test case N covering UNION ALL across 4 actual tables with ORDER BY. This test demonstrates the fix works with real table data, not just literal values. Co-authored-by: mathiasrw <[email protected]>
Contributor
Author
mathiasrw
approved these changes
Nov 19, 2025
Member
|
@copilot Please run |
Ran `yarn jison` to regenerate src/alasqlparser.js from the grammar file. Parser state numbers updated. All tests continue to pass. Co-authored-by: mathiasrw <[email protected]>
Contributor
Author
mathiasrw
approved these changes
Nov 20, 2025
mathiasrw
approved these changes
Nov 20, 2025
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the ORDER BY clause handling when used with three or more UNION operations. Previously, the ORDER BY was incorrectly applied to intermediate SELECT statements rather than the final result set.
Changes Made
Grammar Changes (alasqlparser.jison)
UnionClauseandOrderClause/LimitClausein theSelectrule to align with SQL-99 syntaxSelectWithoutOrderOrLimitrule to prevent ORDER BY from being nested in union clausesUnionClauseto referenceSelectWithoutOrderOrLimitinstead ofSelectyarn jisonto ensure consistency with grammar changesExecution Logic Updates
orderfnand not override it with union clause order; addedorderColumnsto query object for proper union handlingcompileSelect2andcompileSelectGroup2to skip adding order keys duringselectfnexecution when union operations are presentTest Coverage (test7.js)
Code Quality
src/38query.js,src/424select.js, andtest/test7.jsusing PrettierTesting
yarn test-format-allyarn jisonExample
Before (Incorrect):
After (Correct):
Real-World Example (4 Tables):
Fixes #7
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.