Skip to content

fix: parse PostgreSQL ORDER BY ... USING operator (#2925) - #2939

Merged
manticore-projects merged 3 commits into
JSQLParser:masterfrom
ARAYN7011:fix/postgresql-order-by-using-operator
Nov 21, 2026
Merged

manticore-projects merged 3 commits into
JSQLParser:masterfrom
ARAYN7011:fix/postgresql-order-by-using-operator

Conversation

@ARAYN7011

Copy link
Copy Markdown
Contributor

Fixes #2925.

PostgreSQL allows ORDER BY expr USING operator (USING < = ASC, USING > = DESC). OrderByElement() now accepts USING followed by a PostgreSQL operator name (reusing PostgreSqlOperatorName()), stores it in OrderByElement.usingOperator, and renders it in toString() and OrderByDeParser.

Test plan:

  • New SelectTest.testPostgreSqlOrderByUsingOperator (parse + deparse round trip incl. window ORDER BY, NULLS combination, multi-char operator); it does not compile/pass without the change.
  • Full ./gradlew test spotlessCheck green locally.

AI assistance: this change was prepared with Claude Code (AI-assisted) and verified by running the test suite.

🤖 Generated with Claude Code

@manticore-projects

Copy link
Copy Markdown
Contributor

Please fix the Grammar ambiguities.

@ARAYN7011

ARAYN7011 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks. The ambiguity was my change: putting USING as a second alternative inside the ASC/DESC optional made JavaCC report a choice conflict on ASC. I moved USING <operator> into its own optional construct in 2eea3a6. checkGrammarAmbiguity now reports no warnings, spotlessCheck is clean, and SelectTest and the OrderBy tests pass. This sits on top of your master merge.

@manticore-projects
manticore-projects merged commit 811fb79 into JSQLParser:master Nov 21, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you much.

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.

[BUG] JSQLParser : PostgreSQL : ORDER BY ... USING operator fails to parse

2 participants