Skip to content

Support opt-in legacy MySQL GROUP BY ordering - #2595

Merged
manticore-projects merged 2 commits into
JSQLParser:masterfrom
minleejae:feat/legacy-mysql-group-by
Sep 11, 2026
Merged

Support opt-in legacy MySQL GROUP BY ordering#2595
manticore-projects merged 2 commits into
JSQLParser:masterfrom
minleejae:feat/legacy-mysql-group-by

Conversation

@minleejae

@minleejae minleejae commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

MySQL versions before 8.0.13 allow explicit ASC/DESC on GROUP BY items. Parse and preserve this syntax only when callers select Dialect.MYSQL and opt in with withLegacyMySqlGroupBy(true); default and other-dialect parsing keep rejecting it.

Keep the existing grouping expression list and expose directions by list position, so visitors still see the original expressions. Share clause rendering between GroupByElement and GroupByDeParser, preserve directions when appending items, and validate ordering with a separate selectGroupByOrdering feature. Document the option and AST contract.

Validation: full Gradle check and Maven verify; regression tests cover dialect/option isolation, mixed explicit and omitted directions, round trips, custom expression deparsing, column traversal, mutable AST operations, and malformed input.

Integration validation: all twelve existing PRs plus these three independent fixes pass full Gradle check together (6,495 tests; 0 failures/errors; 25 skipped). Existing dialect-enum, shared-index-helper and documentation conflicts were resolved only in the local validation branch.

Fixes #1169.

Syntax reference: https://dev.mysql.com/doc/refman/8.0/en/select.html (the extension was removed in 8.0.13).

Preserve ASC/DESC by grouping-list position and share AST/deparser rendering. Keep existing expression traversal and make appending grouping expressions preserve both the expression list and its directions.

Fixes JSQLParser#1169.
@manticore-projects
manticore-projects merged commit 7cc8638 into JSQLParser:master Sep 11, 2026
9 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

The MySQL folks will be happy! Thank you!

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 this pull request may close these issues.

net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "desc" "DESC"

2 participants