You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the JSQL Parser Version 4.5, I encountered the two following issues when parsing PostgreSQL JSON functions in infix notation (the "arrow" operators).
The query SELECT '{"key": "value"}'::json -> 'key' AS X
yields an exception net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "->" "->".
This extends to all the combinations that I tried for the pattern SELECT [leftOperand]::[datatype] [arrowSymbol] [rightOperand] AS X
where
[leftOperand] is a json object
[datatype] is one of {json, jsonb}
[arrowSymbol] is one of { ->, ->>, #>, #>>}
[rightOperand] is a positive integer, a quoted string or a an expression of the form '{a,b}'.
The query SELECT Y::json -> 'key' AS X
is parsed.
As well as all the combinations that I tried for the above pattern, but where is a non-quoted string (aka a variable name).
The expression Y::json -> 'key'
in this example is exposed as an instance of net.sf.jsqlparser.expression.JSONExpression.
And the right operand ('key' in this example) is the first element of the list net.sf.jsqlparser.expression.JSONExpression.idents.
However, this list idents has private access.
And looking at the source code, I could not find a way to retrieve its elements.
The class JSONExpression contains a getter method for idents, but the code has been commented out.
fails because JSONExpression is currently defined for Column only (but not for an Expression).
Please refere to the source JSQLParser/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt:4175
Please wait for the PR #1676 to get accepted. This will close the Issue automatically.
In the meantime you can pull from that branch yourself and compile from source.
Only @wumpz can accept PRs.
Activity
manticore-projects commentedon Dec 15, 2022
fails because
JSONExpressionis currently defined forColumnonly (but not for anExpression).Please refere to the source JSQLParser/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt:4175
fix: fix JSonExpression, accept Expressions
manticore-projects commentedon Dec 16, 2022
Greetings,
I have fixed that, although we can't make it work with a generic function:
The parser will become way too slow and many performance related tests will fail.
Although Parameters and Sub-Queries are supported.
I have also exposed the
Idents()andOperators(), no idea what happened there.juliencorman commentedon Dec 16, 2022
Great, thank you very much!
Kind regards,
Julien Corman
manticore-projects commentedon Dec 16, 2022
Please wait for the PR #1676 to get accepted. This will close the Issue automatically.
In the meantime you can pull from that branch yourself and compile from source.
Only @wumpz can accept PRs.
Assorted Fixes #4 (#1676)