-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PostgreSQL JSON arrow operators #1696
Comments
SELECT '{"key": "value"}'::json -> 'key' AS X fails because |
Make JSonExpression accept Expressions Add Testcase Expose Idents() and Operators() Fixes JSQLParser#1696
Greetings, I have fixed that, although we can't make it work with a generic function: -- won't work
SELECT myStringFunction(a, b, c)::json -> 'key' AS X The parser will become way too slow and many performance related tests will fail. I have also exposed the |
Great, thank you very much! Kind regards, |
* support clickhouse global keyword in join * fix: add missing public Getter Add public Getter for `updateSets` Fixes #1630 * feat: Clickhouse GLOBAL JOIN All credits to @julianzlzhang fixes #1615 fixes #1535 * feat: IF/ELSE statements supports Block Make `If... Else...` statements work with Blocks Make `Statement()` production work with `Block()` Rewrite the `Block()` related Unit Tests fixes #1682 * fix: Revert unintended changes to the Special Oracle Tests * fix: `SET` statement supports `UserVariable` Make `SetStatement` parse Objects instead of Names only Add Grammar to accept `UserVariable` (e.g. "set @Flag = 1") Add Test Case for `UserVariable` fixes #1682 * feat: Google Spanner Support Replaces PR #1415, all credit goes to @s13o Re-arranged some recently added Tokens in alphabetical order Update Keywords * fix: fix JSonExpression, accept Expressions Make JSonExpression accept Expressions Add Testcase Expose Idents() and Operators() Fixes #1696 * test: add Test for Issue #1237 Co-authored-by: Zhang Zhongliang <zhangzhongliang@xiaomi.com>
Hello,
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 foridents
, but the code has been commented out.Thank you in advance for your help.
Kind regards,
Julien Corman
The text was updated successfully, but these errors were encountered: