File tree 3 files changed +32
-2
lines changed
3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -678,7 +678,7 @@ pub enum Expr {
678
678
} ,
679
679
/// Access a map-like object by field (e.g. `column['field']` or `column[4]`
680
680
/// Note that depending on the dialect, struct like accesses may be
681
- /// parsed as [`ArrayIndex `](Self::ArrayIndex ) or [`MapAccess`](Self::MapAccess)
681
+ /// parsed as [`Subscript `](Self::Subscript ) or [`MapAccess`](Self::MapAccess)
682
682
/// <https://clickhouse.com/docs/en/sql-reference/data-types/map/>
683
683
MapAccess {
684
684
column : Box < Expr > ,
Original file line number Diff line number Diff line change @@ -2038,7 +2038,7 @@ fn parse_array_subscript() {
2038
2038
assert_eq ! ( expect, * subscript) ;
2039
2039
}
2040
2040
2041
- // pg_and_generic().verified_expr("schedule[:2][2:]");
2041
+ pg_and_generic ( ) . verified_expr ( "schedule[:2][2:]" ) ;
2042
2042
}
2043
2043
2044
2044
#[ test]
Original file line number Diff line number Diff line change @@ -344,6 +344,36 @@ fn parse_semi_structured_data_traversal() {
344
344
} ) ] ,
345
345
select. projection
346
346
) ;
347
+
348
+ // a json access used as a key to another json access
349
+ assert_eq ! (
350
+ snowflake( ) . verified_expr( "a[b:c]" ) ,
351
+ Expr :: JsonAccess {
352
+ value: Box :: new( Expr :: Identifier ( Ident :: new( "a" ) ) ) ,
353
+ path: JsonPath {
354
+ path: vec![ JsonPathElem :: Bracket {
355
+ key: Expr :: JsonAccess {
356
+ value: Box :: new( Expr :: Identifier ( Ident :: new( "b" ) ) ) ,
357
+ path: JsonPath {
358
+ path: vec![ JsonPathElem :: Dot {
359
+ key: "c" . to_owned( ) ,
360
+ quoted: false
361
+ } ]
362
+ }
363
+ }
364
+ } ]
365
+ }
366
+ }
367
+ ) ;
368
+
369
+ // unquoted object keys cannot start with a digit
370
+ assert_eq ! (
371
+ snowflake( )
372
+ . parse_sql_statements( "SELECT a:42" )
373
+ . unwrap_err( )
374
+ . to_string( ) ,
375
+ "sql parser error: Expected variant object key name, found: 42"
376
+ ) ;
347
377
}
348
378
349
379
#[ test]
You can’t perform that action at this time.
0 commit comments