@@ -169,7 +169,7 @@ fn parse_where_delete_statement() {
169
169
assert_eq ! ( SQLObjectName ( vec![ "foo" . to_string( ) ] ) , table_name) ;
170
170
171
171
assert_eq ! (
172
- SQLBinaryExpr {
172
+ SQLBinaryOp {
173
173
left: Box :: new( SQLIdentifier ( "name" . to_string( ) ) ) ,
174
174
op: Eq ,
175
175
right: Box :: new( SQLValue ( Value :: Long ( 5 ) ) ) ,
@@ -270,7 +270,7 @@ fn parse_column_aliases() {
270
270
let sql = "SELECT a.col + 1 AS newname FROM foo AS a" ;
271
271
let select = verified_only_select ( sql) ;
272
272
if let SQLSelectItem :: ExpressionWithAlias {
273
- expr : ASTNode :: SQLBinaryExpr {
273
+ expr : ASTNode :: SQLBinaryOp {
274
274
ref op, ref right, ..
275
275
} ,
276
276
ref alias,
@@ -324,8 +324,8 @@ fn parse_select_count_distinct() {
324
324
assert_eq ! (
325
325
& ASTNode :: SQLFunction ( SQLFunction {
326
326
name: SQLObjectName ( vec![ "COUNT" . to_string( ) ] ) ,
327
- args: vec![ ASTNode :: SQLUnary {
328
- operator : SQLOperator :: Plus ,
327
+ args: vec![ ASTNode :: SQLUnaryOp {
328
+ op : SQLOperator :: Plus ,
329
329
expr: Box :: new( ASTNode :: SQLIdentifier ( "x" . to_string( ) ) )
330
330
} ] ,
331
331
over: None ,
@@ -397,7 +397,7 @@ fn parse_escaped_single_quote_string_predicate() {
397
397
WHERE salary <> 'Jim''s salary'";
398
398
let ast = verified_only_select ( sql) ;
399
399
assert_eq ! (
400
- Some ( SQLBinaryExpr {
400
+ Some ( SQLBinaryOp {
401
401
left: Box :: new( SQLIdentifier ( "salary" . to_string( ) ) ) ,
402
402
op: NotEq ,
403
403
right: Box :: new( SQLValue ( Value :: SingleQuotedString (
@@ -414,10 +414,10 @@ fn parse_compound_expr_1() {
414
414
use self :: SQLOperator :: * ;
415
415
let sql = "a + b * c" ;
416
416
assert_eq ! (
417
- SQLBinaryExpr {
417
+ SQLBinaryOp {
418
418
left: Box :: new( SQLIdentifier ( "a" . to_string( ) ) ) ,
419
419
op: Plus ,
420
- right: Box :: new( SQLBinaryExpr {
420
+ right: Box :: new( SQLBinaryOp {
421
421
left: Box :: new( SQLIdentifier ( "b" . to_string( ) ) ) ,
422
422
op: Multiply ,
423
423
right: Box :: new( SQLIdentifier ( "c" . to_string( ) ) )
@@ -433,8 +433,8 @@ fn parse_compound_expr_2() {
433
433
use self :: SQLOperator :: * ;
434
434
let sql = "a * b + c" ;
435
435
assert_eq ! (
436
- SQLBinaryExpr {
437
- left: Box :: new( SQLBinaryExpr {
436
+ SQLBinaryOp {
437
+ left: Box :: new( SQLBinaryOp {
438
438
left: Box :: new( SQLIdentifier ( "a" . to_string( ) ) ) ,
439
439
op: Multiply ,
440
440
right: Box :: new( SQLIdentifier ( "b" . to_string( ) ) )
@@ -452,14 +452,14 @@ fn parse_unary_math() {
452
452
use self :: SQLOperator :: * ;
453
453
let sql = "- a + - b" ;
454
454
assert_eq ! (
455
- SQLBinaryExpr {
456
- left: Box :: new( SQLUnary {
457
- operator : Minus ,
455
+ SQLBinaryOp {
456
+ left: Box :: new( SQLUnaryOp {
457
+ op : Minus ,
458
458
expr: Box :: new( SQLIdentifier ( "a" . to_string( ) ) ) ,
459
459
} ) ,
460
460
op: Plus ,
461
- right: Box :: new( SQLUnary {
462
- operator : Minus ,
461
+ right: Box :: new( SQLUnaryOp {
462
+ op : Minus ,
463
463
expr: Box :: new( SQLIdentifier ( "b" . to_string( ) ) ) ,
464
464
} ) ,
465
465
} ,
@@ -492,24 +492,24 @@ fn parse_not_precedence() {
492
492
use self :: ASTNode :: * ;
493
493
// NOT has higher precedence than OR/AND, so the following must parse as (NOT true) OR true
494
494
let sql = "NOT true OR true" ;
495
- assert_matches ! ( verified_expr( sql) , SQLBinaryExpr {
495
+ assert_matches ! ( verified_expr( sql) , SQLBinaryOp {
496
496
op: SQLOperator :: Or ,
497
497
..
498
498
} ) ;
499
499
500
500
// But NOT has lower precedence than comparison operators, so the following parses as NOT (a IS NULL)
501
501
let sql = "NOT a IS NULL" ;
502
- assert_matches ! ( verified_expr( sql) , SQLUnary {
503
- operator : SQLOperator :: Not ,
502
+ assert_matches ! ( verified_expr( sql) , SQLUnaryOp {
503
+ op : SQLOperator :: Not ,
504
504
..
505
505
} ) ;
506
506
507
507
// NOT has lower precedence than BETWEEN, so the following parses as NOT (1 NOT BETWEEN 1 AND 2)
508
508
let sql = "NOT 1 NOT BETWEEN 1 AND 2" ;
509
509
assert_eq ! (
510
510
verified_expr( sql) ,
511
- SQLUnary {
512
- operator : SQLOperator :: Not ,
511
+ SQLUnaryOp {
512
+ op : SQLOperator :: Not ,
513
513
expr: Box :: new( SQLBetween {
514
514
expr: Box :: new( SQLValue ( Value :: Long ( 1 ) ) ) ,
515
515
low: Box :: new( SQLValue ( Value :: Long ( 1 ) ) ) ,
@@ -523,9 +523,9 @@ fn parse_not_precedence() {
523
523
let sql = "NOT 'a' NOT LIKE 'b'" ;
524
524
assert_eq ! (
525
525
verified_expr( sql) ,
526
- SQLUnary {
527
- operator : SQLOperator :: Not ,
528
- expr: Box :: new( SQLBinaryExpr {
526
+ SQLUnaryOp {
527
+ op : SQLOperator :: Not ,
528
+ expr: Box :: new( SQLBinaryOp {
529
529
left: Box :: new( SQLValue ( Value :: SingleQuotedString ( "a" . into( ) ) ) ) ,
530
530
op: SQLOperator :: NotLike ,
531
531
right: Box :: new( SQLValue ( Value :: SingleQuotedString ( "b" . into( ) ) ) ) ,
@@ -537,8 +537,8 @@ fn parse_not_precedence() {
537
537
let sql = "NOT a NOT IN ('a')" ;
538
538
assert_eq ! (
539
539
verified_expr( sql) ,
540
- SQLUnary {
541
- operator : SQLOperator :: Not ,
540
+ SQLUnaryOp {
541
+ op : SQLOperator :: Not ,
542
542
expr: Box :: new( SQLInList {
543
543
expr: Box :: new( SQLIdentifier ( "a" . into( ) ) ) ,
544
544
list: vec![ SQLValue ( Value :: SingleQuotedString ( "a" . into( ) ) ) ] ,
@@ -557,7 +557,7 @@ fn parse_like() {
557
557
) ;
558
558
let select = verified_only_select ( sql) ;
559
559
assert_eq ! (
560
- ASTNode :: SQLBinaryExpr {
560
+ ASTNode :: SQLBinaryOp {
561
561
left: Box :: new( ASTNode :: SQLIdentifier ( "name" . to_string( ) ) ) ,
562
562
op: if negated {
563
563
SQLOperator :: NotLike
@@ -579,7 +579,7 @@ fn parse_like() {
579
579
) ;
580
580
let select = verified_only_select ( sql) ;
581
581
assert_eq ! (
582
- ASTNode :: SQLIsNull ( Box :: new( ASTNode :: SQLBinaryExpr {
582
+ ASTNode :: SQLIsNull ( Box :: new( ASTNode :: SQLBinaryOp {
583
583
left: Box :: new( ASTNode :: SQLIdentifier ( "name" . to_string( ) ) ) ,
584
584
op: if negated {
585
585
SQLOperator :: NotLike
@@ -666,12 +666,12 @@ fn parse_between_with_expr() {
666
666
assert_eq ! (
667
667
ASTNode :: SQLIsNull ( Box :: new( ASTNode :: SQLBetween {
668
668
expr: Box :: new( ASTNode :: SQLValue ( Value :: Long ( 1 ) ) ) ,
669
- low: Box :: new( SQLBinaryExpr {
669
+ low: Box :: new( SQLBinaryOp {
670
670
left: Box :: new( ASTNode :: SQLValue ( Value :: Long ( 1 ) ) ) ,
671
671
op: Plus ,
672
672
right: Box :: new( ASTNode :: SQLValue ( Value :: Long ( 2 ) ) ) ,
673
673
} ) ,
674
- high: Box :: new( SQLBinaryExpr {
674
+ high: Box :: new( SQLBinaryOp {
675
675
left: Box :: new( ASTNode :: SQLValue ( Value :: Long ( 3 ) ) ) ,
676
676
op: Plus ,
677
677
right: Box :: new( ASTNode :: SQLValue ( Value :: Long ( 4 ) ) ) ,
@@ -684,15 +684,15 @@ fn parse_between_with_expr() {
684
684
let sql = "SELECT * FROM t WHERE 1 = 1 AND 1 + x BETWEEN 1 AND 2" ;
685
685
let select = verified_only_select ( sql) ;
686
686
assert_eq ! (
687
- ASTNode :: SQLBinaryExpr {
688
- left: Box :: new( ASTNode :: SQLBinaryExpr {
687
+ ASTNode :: SQLBinaryOp {
688
+ left: Box :: new( ASTNode :: SQLBinaryOp {
689
689
left: Box :: new( ASTNode :: SQLValue ( Value :: Long ( 1 ) ) ) ,
690
690
op: SQLOperator :: Eq ,
691
691
right: Box :: new( ASTNode :: SQLValue ( Value :: Long ( 1 ) ) ) ,
692
692
} ) ,
693
693
op: SQLOperator :: And ,
694
694
right: Box :: new( ASTNode :: SQLBetween {
695
- expr: Box :: new( ASTNode :: SQLBinaryExpr {
695
+ expr: Box :: new( ASTNode :: SQLBinaryOp {
696
696
left: Box :: new( ASTNode :: SQLValue ( Value :: Long ( 1 ) ) ) ,
697
697
op: SQLOperator :: Plus ,
698
698
right: Box :: new( ASTNode :: SQLIdentifier ( "x" . to_string( ) ) ) ,
@@ -1356,14 +1356,14 @@ fn parse_parens() {
1356
1356
use self :: SQLOperator :: * ;
1357
1357
let sql = "(a + b) - (c + d)" ;
1358
1358
assert_eq ! (
1359
- SQLBinaryExpr {
1360
- left: Box :: new( SQLNested ( Box :: new( SQLBinaryExpr {
1359
+ SQLBinaryOp {
1360
+ left: Box :: new( SQLNested ( Box :: new( SQLBinaryOp {
1361
1361
left: Box :: new( SQLIdentifier ( "a" . to_string( ) ) ) ,
1362
1362
op: Plus ,
1363
1363
right: Box :: new( SQLIdentifier ( "b" . to_string( ) ) )
1364
1364
} ) ) ) ,
1365
1365
op: Minus ,
1366
- right: Box :: new( SQLNested ( Box :: new( SQLBinaryExpr {
1366
+ right: Box :: new( SQLNested ( Box :: new( SQLBinaryOp {
1367
1367
left: Box :: new( SQLIdentifier ( "c" . to_string( ) ) ) ,
1368
1368
op: Plus ,
1369
1369
right: Box :: new( SQLIdentifier ( "d" . to_string( ) ) )
@@ -1376,20 +1376,20 @@ fn parse_parens() {
1376
1376
#[ test]
1377
1377
fn parse_searched_case_expression ( ) {
1378
1378
let sql = "SELECT CASE WHEN bar IS NULL THEN 'null' WHEN bar = 0 THEN '=0' WHEN bar >= 0 THEN '>=0' ELSE '<0' END FROM foo" ;
1379
- use self :: ASTNode :: { SQLBinaryExpr , SQLCase , SQLIdentifier , SQLIsNull , SQLValue } ;
1379
+ use self :: ASTNode :: { SQLBinaryOp , SQLCase , SQLIdentifier , SQLIsNull , SQLValue } ;
1380
1380
use self :: SQLOperator :: * ;
1381
1381
let select = verified_only_select ( sql) ;
1382
1382
assert_eq ! (
1383
1383
& SQLCase {
1384
1384
operand: None ,
1385
1385
conditions: vec![
1386
1386
SQLIsNull ( Box :: new( SQLIdentifier ( "bar" . to_string( ) ) ) ) ,
1387
- SQLBinaryExpr {
1387
+ SQLBinaryOp {
1388
1388
left: Box :: new( SQLIdentifier ( "bar" . to_string( ) ) ) ,
1389
1389
op: Eq ,
1390
1390
right: Box :: new( SQLValue ( Value :: Long ( 0 ) ) )
1391
1391
} ,
1392
- SQLBinaryExpr {
1392
+ SQLBinaryOp {
1393
1393
left: Box :: new( SQLIdentifier ( "bar" . to_string( ) ) ) ,
1394
1394
op: GtEq ,
1395
1395
right: Box :: new( SQLValue ( Value :: Long ( 0 ) ) )
@@ -1543,7 +1543,7 @@ fn parse_joins_on() {
1543
1543
args : vec ! [ ] ,
1544
1544
with_hints : vec ! [ ] ,
1545
1545
} ,
1546
- join_operator : f ( JoinConstraint :: On ( ASTNode :: SQLBinaryExpr {
1546
+ join_operator : f ( JoinConstraint :: On ( ASTNode :: SQLBinaryOp {
1547
1547
left : Box :: new ( ASTNode :: SQLIdentifier ( "c1" . into ( ) ) ) ,
1548
1548
op : SQLOperator :: Eq ,
1549
1549
right : Box :: new ( ASTNode :: SQLIdentifier ( "c2" . into ( ) ) ) ,
@@ -1908,7 +1908,7 @@ fn parse_multiple_statements() {
1908
1908
fn parse_scalar_subqueries ( ) {
1909
1909
use self :: ASTNode :: * ;
1910
1910
let sql = "(SELECT 1) + (SELECT 2)" ;
1911
- assert_matches ! ( verified_expr( sql) , SQLBinaryExpr {
1911
+ assert_matches ! ( verified_expr( sql) , SQLBinaryOp {
1912
1912
op: SQLOperator :: Plus , ..
1913
1913
//left: box SQLSubquery { .. },
1914
1914
//right: box SQLSubquery { .. },
@@ -1928,8 +1928,8 @@ fn parse_exists_subquery() {
1928
1928
let sql = "SELECT * FROM t WHERE NOT EXISTS (SELECT 1)" ;
1929
1929
let select = verified_only_select ( sql) ;
1930
1930
assert_eq ! (
1931
- ASTNode :: SQLUnary {
1932
- operator : SQLOperator :: Not ,
1931
+ ASTNode :: SQLUnaryOp {
1932
+ op : SQLOperator :: Not ,
1933
1933
expr: Box :: new( ASTNode :: SQLExists ( Box :: new( expected_inner) ) ) ,
1934
1934
} ,
1935
1935
select. selection. unwrap( ) ,
0 commit comments