Skip to content

fix: parse PostgreSQL JSON path deletion and existence operators - #2664

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/postgresql-json-path-operators
Sep 21, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/postgresql-json-path-operators

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

PostgreSQL jsonb #- text[] currently becomes an Intersects expression followed by unary minus, so both output paths emit # - and the SQL fails on PostgreSQL. jsonb @? jsonpath is also missing; without whitespace, the lexer can absorb @ into the preceding identifier.

Recognize #- and @? as complete tokens and reuse JsonOperator plus the existing expression precedence loop. Preserve left-associative chains, comparisons and JDBC parameters. In the PostgreSQL dialect, handle existing JSON access operators (->, ->>, #>, #>>) and concatenation at the same precedence, so mixed chains preserve their left-to-right AST structure in both parser modes, and split @ out of unquoted identifiers as already done for #. Existing hash operators and identifier behavior in other dialects retain regression coverage. The legacy -# branch remains accepted for compatibility.

Tests check the actual operator and child AST types, visitors, mutations, missing operands, no-whitespace forms and token locations. JSON path contents remain string expressions; this does not add a JSON path parser.

References: PostgreSQL JSON operators, operator precedence.

Validation:

  • Full Gradle check passed on Java 17, including grammar ambiguity, formatting, static analysis, coverage and the full test suite. JUnit XML totals: 7822 tests, 0 failures/errors, 25 skipped.
  • PostgreSQL 17.11: 24 cases (21 valid, 3 invalid). For all 21 valid cases, the original SQL, toString output and StatementDeParser output executed with identical results.

Signed-off-by: minleejae <mmj9808@gmail.com>
@manticore-projects
manticore-projects merged commit 7f91819 into JSQLParser:master Sep 21, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

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.

2 participants