Skip to content

Commit 14cefc4

Browse files
authored
Merge composite and compound expr test cases (#1615)
1 parent 27822e2 commit 14cefc4

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

tests/sqlparser_common.rs

+30-29
Original file line numberDiff line numberDiff line change
@@ -12389,8 +12389,8 @@ fn parse_create_table_with_bit_types() {
1238912389
fn parse_composite_access_expr() {
1239012390
assert_eq!(
1239112391
verified_expr("f(a).b"),
12392-
Expr::CompositeAccess {
12393-
expr: Box::new(Expr::Function(Function {
12392+
Expr::CompoundFieldAccess {
12393+
root: Box::new(Expr::Function(Function {
1239412394
name: ObjectName(vec![Ident::new("f")]),
1239512395
uses_odbc_syntax: false,
1239612396
parameters: FunctionArguments::None,
@@ -12406,41 +12406,41 @@ fn parse_composite_access_expr() {
1240612406
over: None,
1240712407
within_group: vec![]
1240812408
})),
12409-
key: Ident::new("b")
12409+
access_chain: vec![AccessExpr::Dot(Expr::Identifier(Ident::new("b")))]
1241012410
}
1241112411
);
1241212412

1241312413
// Nested Composite Access
1241412414
assert_eq!(
1241512415
verified_expr("f(a).b.c"),
12416-
Expr::CompositeAccess {
12417-
expr: Box::new(Expr::CompositeAccess {
12418-
expr: Box::new(Expr::Function(Function {
12419-
name: ObjectName(vec![Ident::new("f")]),
12420-
uses_odbc_syntax: false,
12421-
parameters: FunctionArguments::None,
12422-
args: FunctionArguments::List(FunctionArgumentList {
12423-
duplicate_treatment: None,
12424-
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(
12425-
Expr::Identifier(Ident::new("a"))
12426-
))],
12427-
clauses: vec![],
12428-
}),
12429-
null_treatment: None,
12430-
filter: None,
12431-
over: None,
12432-
within_group: vec![]
12433-
})),
12434-
key: Ident::new("b")
12435-
}),
12436-
key: Ident::new("c")
12416+
Expr::CompoundFieldAccess {
12417+
root: Box::new(Expr::Function(Function {
12418+
name: ObjectName(vec![Ident::new("f")]),
12419+
uses_odbc_syntax: false,
12420+
parameters: FunctionArguments::None,
12421+
args: FunctionArguments::List(FunctionArgumentList {
12422+
duplicate_treatment: None,
12423+
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(
12424+
Expr::Identifier(Ident::new("a"))
12425+
))],
12426+
clauses: vec![],
12427+
}),
12428+
null_treatment: None,
12429+
filter: None,
12430+
over: None,
12431+
within_group: vec![]
12432+
})),
12433+
access_chain: vec![
12434+
AccessExpr::Dot(Expr::Identifier(Ident::new("b"))),
12435+
AccessExpr::Dot(Expr::Identifier(Ident::new("c"))),
12436+
]
1243712437
}
1243812438
);
1243912439

1244012440
// Composite Access in Select and Where Clauses
1244112441
let stmt = verified_only_select("SELECT f(a).b FROM t WHERE f(a).b IS NOT NULL");
12442-
let expr = Expr::CompositeAccess {
12443-
expr: Box::new(Expr::Function(Function {
12442+
let expr = Expr::CompoundFieldAccess {
12443+
root: Box::new(Expr::Function(Function {
1244412444
name: ObjectName(vec![Ident::new("f")]),
1244512445
uses_odbc_syntax: false,
1244612446
parameters: FunctionArguments::None,
@@ -12456,14 +12456,15 @@ fn parse_composite_access_expr() {
1245612456
over: None,
1245712457
within_group: vec![],
1245812458
})),
12459-
key: Ident::new("b"),
12459+
access_chain: vec![AccessExpr::Dot(Expr::Identifier(Ident::new("b")))],
1246012460
};
1246112461

1246212462
assert_eq!(stmt.projection[0], SelectItem::UnnamedExpr(expr.clone()));
1246312463
assert_eq!(stmt.selection.unwrap(), Expr::IsNotNull(Box::new(expr)));
1246412464

12465-
// Composite Access with quoted identifier
12466-
verified_only_select("SELECT f(a).\"an id\"");
12465+
// Compound access with quoted identifier.
12466+
all_dialects_where(|d| d.is_delimited_identifier_start('"'))
12467+
.verified_only_select("SELECT f(a).\"an id\"");
1246712468

1246812469
// Composite Access in struct literal
1246912470
all_dialects_where(|d| d.supports_struct_literal()).verified_stmt(

0 commit comments

Comments
 (0)