On 09.12.21 15:04, Himanshu Upadhyaya wrote:
1)
Why we don't support KEY(however is optional as per SQL standard) keyword?
SELECT JSON_OBJECT(KEY 'a' VALUE '123');
ERROR: type "key" does not exist
LINE 1: SELECT JSON_OBJECT(KEY 'a' VALUE '123');
ORACLE is supporting the above syntax.
I can see TODO as below
+json_name_and_value:
+/* TODO This is not supported due to conflicts
+ KEY c_expr VALUE_P json_value_expr %prec POSTFIXOP
+ { $$ = makeJsonKeyValue($2, $4); }
+ |
+*/
but still not very clear what kind of conflict we are mentioning here,
also any plan of finding a solution to that conflict?
The conflict is this:
Consider in subclause 6.33, “<JSON value constructor>”:
<JSON name and value> ::= [ KEY ] <JSON name> VALUE <JSON input expression>
| ...
Because KEY is a <non-reserved word>, this creates an ambiguity. For
example:
key(x) VALUE foo
could be
KEY x VALUE foo
with KEY being the key word and “x” (a <column reference>) as “<JSON
name>”, or
KEY key(x) VALUE foo
with “key(x)” (a <routine invocation>) as “<JSON name>”.
In existing implementations, KEY is resolved as a keyword. So if you
can figure out a way to implement that, go ahead, but I imagine it might
be tricky.