File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -7515,7 +7515,11 @@ impl<'a> Parser<'a> {
7515
7515
with_offset,
7516
7516
with_offset_alias,
7517
7517
} )
7518
- } else if self . parse_keyword ( Keyword :: JSON_TABLE ) {
7518
+ } else if matches ! (
7519
+ self . peek_token( ) . token, Token :: Word ( w)
7520
+ if w. keyword == Keyword :: JSON_TABLE && self . peek_nth_token( 1 ) . token == Token :: LParen
7521
+ ) {
7522
+ self . expect_keyword ( Keyword :: JSON_TABLE ) ?;
7519
7523
self . expect_token ( & Token :: LParen ) ?;
7520
7524
let json_expr = self . parse_expr ( ) ?;
7521
7525
self . expect_token ( & Token :: Comma ) ?;
Original file line number Diff line number Diff line change @@ -2328,6 +2328,26 @@ fn test_json() {
2328
2328
) ;
2329
2329
}
2330
2330
2331
+ #[ test]
2332
+ fn parse_json_table_is_not_reserved ( ) {
2333
+ // JSON_TABLE is not a reserved keyword in PostgreSQL, even though it is in SQL:2023
2334
+ // see: https://en.wikipedia.org/wiki/List_of_SQL_reserved_words
2335
+ match pg ( ) . verified_only_select ( "SELECT * FROM JSON_TABLE" ) {
2336
+ Select { from, .. } => {
2337
+ assert_eq ! ( 1 , from. len( ) ) ;
2338
+ match & from[ 0 ] . relation {
2339
+ TableFactor :: Table {
2340
+ name : ObjectName ( name) ,
2341
+ ..
2342
+ } => {
2343
+ assert_eq ! ( "JSON_TABLE" , name[ 0 ] . value) ;
2344
+ }
2345
+ _ => unreachable ! ( ) ,
2346
+ }
2347
+ }
2348
+ }
2349
+ }
2350
+
2331
2351
#[ test]
2332
2352
fn test_composite_value ( ) {
2333
2353
let sql = "SELECT (on_hand.item).name FROM on_hand WHERE (on_hand.item).price > 9" ;
You can’t perform that action at this time.
0 commit comments