@@ -5193,101 +5193,109 @@ JsonFunction JsonFunction() : {
51935193 Column column = null;
51945194 JsonKeyValuePair keyValuePair;
51955195
5196+ Object key = null;
51965197 Expression expression = null;
51975198 JsonFunctionExpression functionExpression;
51985199
51995200}
52005201{
52015202 (
5202- (
5203- ( <K_JSON_OBJECT>
5204- "(" { result.setType( JsonFunctionType.OBJECT ); }
5205- (
5203+ ( <K_JSON_OBJECT>
5204+ "(" { result.setType( JsonFunctionType.OBJECT ); }
5205+ (
5206+ // SQL2016 compliant Syntax
5207+ LOOKAHEAD(2) (
5208+ LOOKAHEAD(2) (
5209+ "KEY" { usingKeyKeyword = true; } ( keyToken = <S_CHAR_LITERAL> { key = keyToken.image; } | key = Column() )
5210+ )
5211+ |
5212+ keyToken = <S_CHAR_LITERAL> { key = keyToken.image; }
5213+ |
5214+ key = Column()
5215+ )
5216+
5217+ ( LOOKAHEAD(2)
5218+ ( ":" | "," { result.setType( JsonFunctionType.POSTGRES_OBJECT ); } | "VALUE" { usingValueKeyword = true; } )
52065219 (
5207- // SQL2016 compliant Syntax
5208- (
5209- [ "KEY" { usingKeyKeyword = true; } ]
5210- keyToken = <S_CHAR_LITERAL>
5220+ expression = Expression()
5221+ )
5222+ [ <K_FORMAT> <K_JSON> { usingFormatJason = true; } ]
5223+ )?
5224+ {
5225+ if (expression !=null) {
5226+ keyValuePair = new JsonKeyValuePair( key, expression, usingKeyKeyword, usingValueKeyword );
5227+ keyValuePair.setUsingFormatJson( usingFormatJason );
5228+ result.add(keyValuePair);
5229+ } else {
5230+ result.setType( JsonFunctionType.POSTGRES_OBJECT );
5231+ keyValuePair = new JsonKeyValuePair( key, null, false, false );
5232+ result.add(keyValuePair);
5233+ }
5234+ }
52115235
5212- ( LOOKAHEAD(2)
5213- ( ":" | "," { result.setType( JsonFunctionType.POSTGRES_OBJECT ); } | "VALUE" { usingValueKeyword = true; } )
5214- (
5215- expression = Expression()
5216- )
5217- [ <K_FORMAT> <K_JSON> { usingFormatJason = true; } ]
5218- )? {
5219- if (expression !=null) {
5220- keyValuePair = new JsonKeyValuePair( keyToken.image, expression, usingKeyKeyword, usingValueKeyword );
5221- keyValuePair.setUsingFormatJson( usingFormatJason );
5222- result.add(keyValuePair);
5223- } else {
5224- result.setType( JsonFunctionType.POSTGRES_OBJECT );
5225- keyValuePair = new JsonKeyValuePair( keyToken.image, null, false, false );
5226- result.add(keyValuePair);
5227- }
5228- }
5229-
5230- // --- Next Elements
5231- ( "," { usingKeyKeyword = false; usingValueKeyword = false; }
5232- [ "KEY" { usingKeyKeyword = true; } ]
5233- keyToken = <S_CHAR_LITERAL>
5234- ( ":" | "," { result.setType( JsonFunctionType.MYSQL_OBJECT ); } | "VALUE" { usingValueKeyword = true; } )
5235- (
5236- expression = Expression() { keyValuePair = new JsonKeyValuePair( keyToken.image, expression, usingKeyKeyword, usingValueKeyword ); result.add(keyValuePair); }
5237- )
5238- [ <K_FORMAT> <K_JSON> { keyValuePair.setUsingFormatJson( true ); } ]
5239- )*
5236+ // --- Next Elements
5237+ ( "," { usingKeyKeyword = false; usingValueKeyword = false; }
5238+ (
5239+ LOOKAHEAD(2) (
5240+ "KEY" { usingKeyKeyword = true; } ( keyToken = <S_CHAR_LITERAL> { key = keyToken.image; } | key = Column() )
52405241 )
5241- )?
5242+ |
5243+ keyToken = <S_CHAR_LITERAL> { key = keyToken.image; }
5244+ |
5245+ key = Column()
5246+ )
5247+ ( ":" | "," { result.setType( JsonFunctionType.MYSQL_OBJECT ); } | "VALUE" { usingValueKeyword = true; } )
5248+ expression = Expression() { keyValuePair = new JsonKeyValuePair( key, expression, usingKeyKeyword, usingValueKeyword ); result.add(keyValuePair); }
5249+ [ <K_FORMAT> <K_JSON> { keyValuePair.setUsingFormatJson( true ); } ]
5250+ )*
5251+ )?
52425252
5243- [
5244- (
5245- <K_NULL> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.NULL ); }
5246- )
5247- |
5248- (
5249- <K_ABSENT> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.ABSENT ); }
5250- )
5251- ]
5253+ [
5254+ (
5255+ <K_NULL> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.NULL ); }
5256+ )
5257+ |
5258+ (
5259+ <K_ABSENT> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.ABSENT ); }
5260+ )
5261+ ]
52525262
5253- [
5254- (
5255- <K_WITH> <K_UNIQUE> <K_KEYS> { result.setUniqueKeysType( JsonAggregateUniqueKeysType.WITH ); }
5256- )
5257- |
5258- (
5259- <K_WITHOUT> <K_UNIQUE> <K_KEYS> { result.setUniqueKeysType( JsonAggregateUniqueKeysType.WITHOUT ); }
5260- )
5261- ]
5263+ [
5264+ (
5265+ <K_WITH> <K_UNIQUE> <K_KEYS> { result.setUniqueKeysType( JsonAggregateUniqueKeysType.WITH ); }
5266+ )
5267+ |
5268+ (
5269+ <K_WITHOUT> <K_UNIQUE> <K_KEYS> { result.setUniqueKeysType( JsonAggregateUniqueKeysType.WITHOUT ); }
5270+ )
5271+ ]
5272+ ")"
5273+ )
5274+ |
5275+ (
5276+ <K_JSON_ARRAY> { result.setType( JsonFunctionType.ARRAY ); }
5277+ "("
5278+ (
5279+ LOOKAHEAD(2) (
5280+ <K_NULL> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.NULL ); }
52625281 )
5263- ")"
5264- )
5265- |
5266- (
5267- <K_JSON_ARRAY> { result.setType( JsonFunctionType.ARRAY ); }
5268- "("
5282+ |
5283+ expression=Expression() { functionExpression = new JsonFunctionExpression( expression ); result.add( functionExpression ); }
5284+
5285+ [ LOOKAHEAD(2) <K_FORMAT> <K_JSON> { functionExpression.setUsingFormatJson( true ); } ]
52695286 (
5270- LOOKAHEAD(2) (
5271- <K_NULL> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.NULL ); }
5272- )
5273- |
5287+ ","
52745288 expression=Expression() { functionExpression = new JsonFunctionExpression( expression ); result.add( functionExpression ); }
5275-
52765289 [ LOOKAHEAD(2) <K_FORMAT> <K_JSON> { functionExpression.setUsingFormatJson( true ); } ]
5277- (
5278- ","
5279- expression=Expression() { functionExpression = new JsonFunctionExpression( expression ); result.add( functionExpression ); }
5280- [ LOOKAHEAD(2) <K_FORMAT> <K_JSON> { functionExpression.setUsingFormatJson( true ); } ]
5281- )*
52825290 )*
5291+ )*
52835292
5284- [
5285- <K_ABSENT> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.ABSENT ); }
5286- ]
5293+ [
5294+ <K_ABSENT> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.ABSENT ); }
5295+ ]
52875296
5288- ")"
5289- )
5290- )
5297+ ")"
5298+ )
52915299 )
52925300
52935301 {
@@ -5298,6 +5306,7 @@ JsonFunction JsonFunction() : {
52985306JsonAggregateFunction JsonAggregateFunction() : {
52995307 JsonAggregateFunction result = new JsonAggregateFunction();
53005308 Token token;
5309+ Object key;
53015310 Expression expression;
53025311 List<OrderByElement> expressionOrderByList = null;
53035312
@@ -5312,10 +5321,32 @@ JsonAggregateFunction JsonAggregateFunction() : {
53125321 (
53135322 ( <K_JSON_OBJECTAGG>
53145323 "(" { result.setType( JsonFunctionType.OBJECT ); }
5315- [ "KEY" { result.setUsingKeyKeyword( true ); } ]
5316- ( token = <DT_ZONE> | token = <S_DOUBLE> | token = <S_LONG> | token = <S_HEX> | token = <S_CHAR_LITERAL> | token = <S_IDENTIFIER> | token = <S_QUOTED_IDENTIFIER> ) { result.setKey( token.image ); }
5317- ( ":" | "VALUE" {result.setUsingValueKeyword( true ); } )
5318- ( token = <S_IDENTIFIER> | token = <S_QUOTED_IDENTIFIER> ) { result.setValue( token.image ); }
5324+ (
5325+ LOOKAHEAD(2) (
5326+ "KEY" { result.setUsingKeyKeyword( true ); }
5327+ (
5328+ ( token = <DT_ZONE> | token = <S_DOUBLE> | token = <S_LONG> | token = <S_HEX> | token = <S_CHAR_LITERAL> )
5329+ {
5330+ key = token.image;
5331+ }
5332+ |
5333+ key = Column()
5334+ )
5335+ )
5336+ |
5337+ ( token = <DT_ZONE> | token = <S_DOUBLE> | token = <S_LONG> | token = <S_HEX> | token = <S_CHAR_LITERAL> )
5338+ {
5339+ key = token.image;
5340+ }
5341+ |
5342+ key = Column()
5343+ )
5344+ {
5345+ result.setKey( key );
5346+ }
5347+
5348+ ( ":" | "," { result.setType( JsonFunctionType.MYSQL_OBJECT ); } | "VALUE" {result.setUsingValueKeyword( true ); } )
5349+ expression = Expression() { result.setValue( expression ); }
53195350
53205351 [ <K_FORMAT> <K_JSON> { result.setUsingFormatJson( true ); } ]
53215352
0 commit comments