Skip to content

Separate JSON operators with spaces so #> deparses correctly - #2487

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
dngr2:json-hash-arrow-spacing
Aug 19, 2026
Merged

Separate JSON operators with spaces so #> deparses correctly#2487
manticore-projects merged 1 commit into
JSQLParser:masterfrom
dngr2:json-hash-arrow-spacing

Conversation

@dngr2

@dngr2 dngr2 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

JsonExpression.toString() appends each operator directly onto its operand, so
a #> '{b}' deparses to a#>'{b}'. Because # is a legal identifier character,
that output re-parses as a# > '{b}' -- a GreaterThan comparison rather than
the original JSON expression, so deparse+reparse is not round-trip safe.

Emit a space on each side of the operator, matching how the JsonOperator is printed
elsewhere. Added a test that parses #> and #>>, deparses, and checks the result
still parses back to a JsonExpression.

JsonExpression.toString glued each operator directly onto its operand, so
a #> ... deparsed as a#>... . Because # is a legal identifier character, that
re-parses as a# > ... -- a GreaterThan, a different tree from the original
JsonExpression. Emit a space on each side of the operator, matching the
JsonOperator visitor.
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you much!

@manticore-projects
manticore-projects merged commit 55b2363 into JSQLParser:master Aug 19, 2026
7 checks passed
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