@@ -166,7 +166,7 @@ fn parse_where_delete_statement() {
166
166
assert_eq ! ( ObjectName ( vec![ "foo" . to_string( ) ] ) , table_name) ;
167
167
168
168
assert_eq ! (
169
- Expr :: BinaryExpr {
169
+ Expr :: BinaryOp {
170
170
left: Box :: new( Expr :: Ident ( "name" . to_string( ) ) ) ,
171
171
op: Operator :: Eq ,
172
172
right: Box :: new( Expr :: Value ( Value :: Long ( 5 ) ) ) ,
@@ -259,7 +259,7 @@ fn parse_column_aliases() {
259
259
let sql = "SELECT a.col + 1 AS newname FROM foo AS a" ;
260
260
let select = verified_only_select ( sql) ;
261
261
if let SelectItem :: NamedExpr {
262
- expr : Expr :: BinaryExpr {
262
+ expr : Expr :: BinaryOp {
263
263
ref op, ref right, ..
264
264
} ,
265
265
ref alias,
@@ -313,8 +313,8 @@ fn parse_select_count_distinct() {
313
313
assert_eq ! (
314
314
& Expr :: Function ( Function {
315
315
name: ObjectName ( vec![ "COUNT" . to_string( ) ] ) ,
316
- args: vec![ Expr :: Unary {
317
- operator : Operator :: Plus ,
316
+ args: vec![ Expr :: UnaryOp {
317
+ op : Operator :: Plus ,
318
318
expr: Box :: new( Expr :: Ident ( "x" . to_string( ) ) )
319
319
} ] ,
320
320
over: None ,
@@ -384,7 +384,7 @@ fn parse_escaped_single_quote_string_predicate() {
384
384
WHERE salary <> 'Jim''s salary'";
385
385
let ast = verified_only_select ( sql) ;
386
386
assert_eq ! (
387
- Some ( Expr :: BinaryExpr {
387
+ Some ( Expr :: BinaryOp {
388
388
left: Box :: new( Expr :: Ident ( "salary" . to_string( ) ) ) ,
389
389
op: Operator :: NotEq ,
390
390
right: Box :: new( Expr :: Value ( Value :: SingleQuotedString (
@@ -399,10 +399,10 @@ fn parse_escaped_single_quote_string_predicate() {
399
399
fn parse_compound_expr_1 ( ) {
400
400
let sql = "a + b * c" ;
401
401
assert_eq ! (
402
- Expr :: BinaryExpr {
402
+ Expr :: BinaryOp {
403
403
left: Box :: new( Expr :: Ident ( "a" . to_string( ) ) ) ,
404
404
op: Operator :: Plus ,
405
- right: Box :: new( Expr :: BinaryExpr {
405
+ right: Box :: new( Expr :: BinaryOp {
406
406
left: Box :: new( Expr :: Ident ( "b" . to_string( ) ) ) ,
407
407
op: Operator :: Multiply ,
408
408
right: Box :: new( Expr :: Ident ( "c" . to_string( ) ) )
@@ -416,8 +416,8 @@ fn parse_compound_expr_1() {
416
416
fn parse_compound_expr_2 ( ) {
417
417
let sql = "a * b + c" ;
418
418
assert_eq ! (
419
- Expr :: BinaryExpr {
420
- left: Box :: new( Expr :: BinaryExpr {
419
+ Expr :: BinaryOp {
420
+ left: Box :: new( Expr :: BinaryOp {
421
421
left: Box :: new( Expr :: Ident ( "a" . to_string( ) ) ) ,
422
422
op: Operator :: Multiply ,
423
423
right: Box :: new( Expr :: Ident ( "b" . to_string( ) ) )
@@ -433,14 +433,14 @@ fn parse_compound_expr_2() {
433
433
fn parse_unary_math ( ) {
434
434
let sql = "- a + - b" ;
435
435
assert_eq ! (
436
- Expr :: BinaryExpr {
437
- left: Box :: new( Expr :: Unary {
438
- operator : Operator :: Minus ,
436
+ Expr :: BinaryOp {
437
+ left: Box :: new( Expr :: UnaryOp {
438
+ op : Operator :: Minus ,
439
439
expr: Box :: new( Expr :: Ident ( "a" . to_string( ) ) ) ,
440
440
} ) ,
441
441
op: Operator :: Plus ,
442
- right: Box :: new( Expr :: Unary {
443
- operator : Operator :: Minus ,
442
+ right: Box :: new( Expr :: UnaryOp {
443
+ op : Operator :: Minus ,
444
444
expr: Box :: new( Expr :: Ident ( "b" . to_string( ) ) ) ,
445
445
} ) ,
446
446
} ,
@@ -470,24 +470,24 @@ fn parse_is_not_null() {
470
470
fn parse_not_precedence ( ) {
471
471
// NOT has higher precedence than OR/AND, so the following must parse as (NOT true) OR true
472
472
let sql = "NOT true OR true" ;
473
- assert_matches ! ( verified_expr( sql) , Expr :: BinaryExpr {
473
+ assert_matches ! ( verified_expr( sql) , Expr :: BinaryOp {
474
474
op: Operator :: Or ,
475
475
..
476
476
} ) ;
477
477
478
478
// But NOT has lower precedence than comparison operators, so the following parses as NOT (a IS NULL)
479
479
let sql = "NOT a IS NULL" ;
480
- assert_matches ! ( verified_expr( sql) , Expr :: Unary {
481
- operator : Operator :: Not ,
480
+ assert_matches ! ( verified_expr( sql) , Expr :: UnaryOp {
481
+ op : Operator :: Not ,
482
482
..
483
483
} ) ;
484
484
485
485
// NOT has lower precedence than BETWEEN, so the following parses as NOT (1 NOT BETWEEN 1 AND 2)
486
486
let sql = "NOT 1 NOT BETWEEN 1 AND 2" ;
487
487
assert_eq ! (
488
488
verified_expr( sql) ,
489
- Expr :: Unary {
490
- operator : Operator :: Not ,
489
+ Expr :: UnaryOp {
490
+ op : Operator :: Not ,
491
491
expr: Box :: new( Expr :: Between {
492
492
expr: Box :: new( Expr :: Value ( Value :: Long ( 1 ) ) ) ,
493
493
low: Box :: new( Expr :: Value ( Value :: Long ( 1 ) ) ) ,
@@ -501,9 +501,9 @@ fn parse_not_precedence() {
501
501
let sql = "NOT 'a' NOT LIKE 'b'" ;
502
502
assert_eq ! (
503
503
verified_expr( sql) ,
504
- Expr :: Unary {
505
- operator : Operator :: Not ,
506
- expr: Box :: new( Expr :: BinaryExpr {
504
+ Expr :: UnaryOp {
505
+ op : Operator :: Not ,
506
+ expr: Box :: new( Expr :: BinaryOp {
507
507
left: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "a" . into( ) ) ) ) ,
508
508
op: Operator :: NotLike ,
509
509
right: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "b" . into( ) ) ) ) ,
@@ -515,8 +515,8 @@ fn parse_not_precedence() {
515
515
let sql = "NOT a NOT IN ('a')" ;
516
516
assert_eq ! (
517
517
verified_expr( sql) ,
518
- Expr :: Unary {
519
- operator : Operator :: Not ,
518
+ Expr :: UnaryOp {
519
+ op : Operator :: Not ,
520
520
expr: Box :: new( Expr :: InList {
521
521
expr: Box :: new( Expr :: Ident ( "a" . into( ) ) ) ,
522
522
list: vec![ Expr :: Value ( Value :: SingleQuotedString ( "a" . into( ) ) ) ] ,
@@ -535,7 +535,7 @@ fn parse_like() {
535
535
) ;
536
536
let select = verified_only_select ( sql) ;
537
537
assert_eq ! (
538
- Expr :: BinaryExpr {
538
+ Expr :: BinaryOp {
539
539
left: Box :: new( Expr :: Ident ( "name" . to_string( ) ) ) ,
540
540
op: if negated {
541
541
Operator :: NotLike
@@ -555,7 +555,7 @@ fn parse_like() {
555
555
) ;
556
556
let select = verified_only_select ( sql) ;
557
557
assert_eq ! (
558
- Expr :: IsNull ( Box :: new( Expr :: BinaryExpr {
558
+ Expr :: IsNull ( Box :: new( Expr :: BinaryOp {
559
559
left: Box :: new( Expr :: Ident ( "name" . to_string( ) ) ) ,
560
560
op: if negated {
561
561
Operator :: NotLike
@@ -638,12 +638,12 @@ fn parse_between_with_expr() {
638
638
assert_eq ! (
639
639
Expr :: IsNull ( Box :: new( Expr :: Between {
640
640
expr: Box :: new( Expr :: Value ( Value :: Long ( 1 ) ) ) ,
641
- low: Box :: new( Expr :: BinaryExpr {
641
+ low: Box :: new( Expr :: BinaryOp {
642
642
left: Box :: new( Expr :: Value ( Value :: Long ( 1 ) ) ) ,
643
643
op: Operator :: Plus ,
644
644
right: Box :: new( Expr :: Value ( Value :: Long ( 2 ) ) ) ,
645
645
} ) ,
646
- high: Box :: new( Expr :: BinaryExpr {
646
+ high: Box :: new( Expr :: BinaryOp {
647
647
left: Box :: new( Expr :: Value ( Value :: Long ( 3 ) ) ) ,
648
648
op: Operator :: Plus ,
649
649
right: Box :: new( Expr :: Value ( Value :: Long ( 4 ) ) ) ,
@@ -656,15 +656,15 @@ fn parse_between_with_expr() {
656
656
let sql = "SELECT * FROM t WHERE 1 = 1 AND 1 + x BETWEEN 1 AND 2" ;
657
657
let select = verified_only_select ( sql) ;
658
658
assert_eq ! (
659
- Expr :: BinaryExpr {
660
- left: Box :: new( Expr :: BinaryExpr {
659
+ Expr :: BinaryOp {
660
+ left: Box :: new( Expr :: BinaryOp {
661
661
left: Box :: new( Expr :: Value ( Value :: Long ( 1 ) ) ) ,
662
662
op: Operator :: Eq ,
663
663
right: Box :: new( Expr :: Value ( Value :: Long ( 1 ) ) ) ,
664
664
} ) ,
665
665
op: Operator :: And ,
666
666
right: Box :: new( Expr :: Between {
667
- expr: Box :: new( Expr :: BinaryExpr {
667
+ expr: Box :: new( Expr :: BinaryOp {
668
668
left: Box :: new( Expr :: Value ( Value :: Long ( 1 ) ) ) ,
669
669
op: Operator :: Plus ,
670
670
right: Box :: new( Expr :: Ident ( "x" . to_string( ) ) ) ,
@@ -1160,14 +1160,14 @@ fn parse_delimited_identifiers() {
1160
1160
fn parse_parens ( ) {
1161
1161
let sql = "(a + b) - (c + d)" ;
1162
1162
assert_eq ! (
1163
- Expr :: BinaryExpr {
1164
- left: Box :: new( Expr :: Nested ( Box :: new( Expr :: BinaryExpr {
1163
+ Expr :: BinaryOp {
1164
+ left: Box :: new( Expr :: Nested ( Box :: new( Expr :: BinaryOp {
1165
1165
left: Box :: new( Expr :: Ident ( "a" . to_string( ) ) ) ,
1166
1166
op: Operator :: Plus ,
1167
1167
right: Box :: new( Expr :: Ident ( "b" . to_string( ) ) )
1168
1168
} ) ) ) ,
1169
1169
op: Operator :: Minus ,
1170
- right: Box :: new( Expr :: Nested ( Box :: new( Expr :: BinaryExpr {
1170
+ right: Box :: new( Expr :: Nested ( Box :: new( Expr :: BinaryOp {
1171
1171
left: Box :: new( Expr :: Ident ( "c" . to_string( ) ) ) ,
1172
1172
op: Operator :: Plus ,
1173
1173
right: Box :: new( Expr :: Ident ( "d" . to_string( ) ) )
@@ -1186,12 +1186,12 @@ fn parse_searched_case_expression() {
1186
1186
operand: None ,
1187
1187
conditions: vec![
1188
1188
Expr :: IsNull ( Box :: new( Expr :: Ident ( "bar" . to_string( ) ) ) ) ,
1189
- Expr :: BinaryExpr {
1189
+ Expr :: BinaryOp {
1190
1190
left: Box :: new( Expr :: Ident ( "bar" . to_string( ) ) ) ,
1191
1191
op: Operator :: Eq ,
1192
1192
right: Box :: new( Expr :: Value ( Value :: Long ( 0 ) ) )
1193
1193
} ,
1194
- Expr :: BinaryExpr {
1194
+ Expr :: BinaryOp {
1195
1195
left: Box :: new( Expr :: Ident ( "bar" . to_string( ) ) ) ,
1196
1196
op: Operator :: GtEq ,
1197
1197
right: Box :: new( Expr :: Value ( Value :: Long ( 0 ) ) )
@@ -1291,7 +1291,7 @@ fn parse_joins_on() {
1291
1291
args : vec ! [ ] ,
1292
1292
with_hints : vec ! [ ] ,
1293
1293
} ,
1294
- join_operator : f ( JoinConstraint :: On ( Expr :: BinaryExpr {
1294
+ join_operator : f ( JoinConstraint :: On ( Expr :: BinaryOp {
1295
1295
left : Box :: new ( Expr :: Ident ( "c1" . into ( ) ) ) ,
1296
1296
op : Operator :: Eq ,
1297
1297
right : Box :: new ( Expr :: Ident ( "c2" . into ( ) ) ) ,
@@ -1588,7 +1588,7 @@ fn parse_multiple_statements() {
1588
1588
#[ test]
1589
1589
fn parse_scalar_subqueries ( ) {
1590
1590
let sql = "(SELECT 1) + (SELECT 2)" ;
1591
- assert_matches ! ( verified_expr( sql) , Expr :: BinaryExpr {
1591
+ assert_matches ! ( verified_expr( sql) , Expr :: BinaryOp {
1592
1592
op: Operator :: Plus , ..
1593
1593
//left: box SQLSubquery { .. },
1594
1594
//right: box SQLSubquery { .. },
@@ -1608,8 +1608,8 @@ fn parse_exists_subquery() {
1608
1608
let sql = "SELECT * FROM t WHERE NOT EXISTS (SELECT 1)" ;
1609
1609
let select = verified_only_select ( sql) ;
1610
1610
assert_eq ! (
1611
- Expr :: Unary {
1612
- operator : Operator :: Not ,
1611
+ Expr :: UnaryOp {
1612
+ op : Operator :: Not ,
1613
1613
expr: Box :: new( Expr :: Exists ( Box :: new( expected_inner) ) ) ,
1614
1614
} ,
1615
1615
select. selection. unwrap( ) ,
0 commit comments