File tree Expand file tree Collapse file tree 2 files changed +35
-7
lines changed Expand file tree Collapse file tree 2 files changed +35
-7
lines changed Original file line number Diff line number Diff line change @@ -283,6 +283,7 @@ mod tests {
283
283
parse ! ( r#"@a.b[*]"# ) ;
284
284
parse ! ( r#"@"a".b[*]"# ) ;
285
285
parse ! ( r#"tables.items[*].product.*.nest"# ) ;
286
+ parse ! ( r#"a.b.c['item']."d"[5].e['s'].f[1+2]"# ) ;
286
287
}
287
288
288
289
#[ test]
@@ -322,6 +323,33 @@ mod tests {
322
323
parse ! ( r#"foo(x, y)[*].*.b[5]"# ) ;
323
324
}
324
325
326
+ #[ test]
327
+ fn test_pathexpr_struct ( ) {
328
+ let res = parse ! ( r#"a.b.c['item']."d"[5].e['s'].f[1+2]"# ) ;
329
+
330
+ if let ast:: ExprKind :: Query ( ast:: AstNode {
331
+ node :
332
+ ast:: Query {
333
+ set :
334
+ ast:: AstNode {
335
+ node : ast:: QuerySet :: Expr ( ref e) ,
336
+ ..
337
+ } ,
338
+ ..
339
+ } ,
340
+ ..
341
+ } ) = res. kind
342
+ {
343
+ if let ast:: ExprKind :: Path ( p) = & e. kind {
344
+ assert_eq ! ( 9 , p. node. steps. len( ) )
345
+ } else {
346
+ panic ! ( "PathExpr test failed!" ) ;
347
+ }
348
+ } else {
349
+ panic ! ( "PathExpr test failed!" ) ;
350
+ }
351
+ }
352
+
325
353
#[ test]
326
354
#[ should_panic]
327
355
fn erroneous ( ) {
Original file line number Diff line number Diff line change @@ -964,21 +964,21 @@ FunctionArgName: ast::SymbolPrimitive = {
964
964
// See the path expression conformance tests under `partiql-tests` or parser unit-tests for more examples.
965
965
PathSteps: Vec<ast::PathStep> = {
966
966
<path:PathSteps> "." <v:PathExprVarRef> => {
967
- vec![ast::PathStep::PathExpr( ast::PathExpr{ index: Box::new(v) })]
967
+ let mut steps = path;
968
+ steps.push(ast::PathStep::PathExpr( ast::PathExpr{ index: Box::new(v) }));
969
+ steps
968
970
},
969
971
<lo:@L> <path:PathSteps> "[" "*" "]" <hi:@R> => {
970
- vec![ast::PathStep::PathWildCard]
972
+ let mut steps = path;
973
+ steps.push(ast::PathStep::PathWildCard);
974
+ steps
971
975
},
972
976
<lo:@L> <path:PathSteps> "." "*" <hi:@R> => {
973
- let step = ast::PathStep::PathUnpivot;
974
-
975
977
let mut steps = path;
976
- steps.push(step );
978
+ steps.push(ast::PathStep::PathUnpivot );
977
979
steps
978
980
// ast::Path{ root:path.root, steps }
979
981
},
980
- // TODO Add path expression with CAST E.g. {'attr': 1, 'b':2}[CAST('at' || 'tr' AS STRING)]
981
- // once https://github.com/partiql/partiql-lang-rust/pull/122 is merged
982
982
<lo:@L> <path:PathSteps> "[" <expr:ExprQuery> "]" <hi:@R> => {
983
983
let step = ast::PathStep::PathExpr(
984
984
ast::PathExpr{
You can’t perform that action at this time.
0 commit comments