@@ -567,19 +567,16 @@ fn parse_not_precedence() {
567
567
) ;
568
568
569
569
// NOT has lower precedence than LIKE, so the following parses as NOT ('a' NOT LIKE 'b')
570
- let sql = "CAST( 'a' AS NOT) NOT LIKE 'b'" ;
570
+ let sql = "NOT 'a' NOT LIKE 'b'" ;
571
571
assert_eq ! (
572
572
verified_expr( sql) ,
573
- Expr :: BinaryOp {
574
- left: Box :: new( Expr :: Cast {
575
- expr: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "a" . into( ) ) ) ) ,
576
- data_type: DataType :: Custom ( ObjectName ( vec![ Ident {
577
- value: "NOT" . into( ) ,
578
- quote_style: None
579
- } ] ) )
573
+ Expr :: UnaryOp {
574
+ op: UnaryOperator :: Not ,
575
+ expr: Box :: new( Expr :: BinaryOp {
576
+ left: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "a" . into( ) ) ) ) ,
577
+ op: BinaryOperator :: NotLike ,
578
+ right: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "b" . into( ) ) ) ) ,
580
579
} ) ,
581
- op: BinaryOperator :: NotLike ,
582
- right: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "b" . into( ) ) ) )
583
580
} ,
584
581
) ;
585
582
@@ -1439,40 +1436,38 @@ fn parse_literal_string() {
1439
1436
1440
1437
#[ test]
1441
1438
fn parse_literal_date ( ) {
1442
- let sql = "SELECT CAST( '1999-01-01' AS date) " ;
1439
+ let sql = "SELECT date '1999-01-01'" ;
1443
1440
let select = verified_only_select ( sql) ;
1444
1441
assert_eq ! (
1445
- & Expr :: Cast {
1446
- expr : Box :: new ( Expr :: Value ( Value :: SingleQuotedString ( "1999-01-01" . into ( ) ) ) ) ,
1447
- data_type : DataType :: Date
1442
+ & Expr :: TypedString {
1443
+ data_type : DataType :: Date ,
1444
+ value : "1999-01-01" . into ( )
1448
1445
} ,
1449
1446
expr_from_projection( only( & select. projection) ) ,
1450
1447
) ;
1451
1448
}
1452
1449
1453
1450
#[ test]
1454
1451
fn parse_literal_time ( ) {
1455
- let sql = "SELECT CAST( '01:23:34' AS time) " ;
1452
+ let sql = "SELECT time '01:23:34'" ;
1456
1453
let select = verified_only_select ( sql) ;
1457
1454
assert_eq ! (
1458
- & Expr :: Cast {
1459
- expr : Box :: new ( Expr :: Value ( Value :: SingleQuotedString ( "01:23:34" . into ( ) ) ) ) ,
1460
- data_type : DataType :: Time
1455
+ & Expr :: TypedString {
1456
+ data_type : DataType :: Time ,
1457
+ value : "01:23:34" . into ( )
1461
1458
} ,
1462
1459
expr_from_projection( only( & select. projection) ) ,
1463
1460
) ;
1464
1461
}
1465
1462
1466
1463
#[ test]
1467
1464
fn parse_literal_timestamp ( ) {
1468
- let sql = "SELECT CAST( '1999-01-01 01:23:34' AS timestamp) " ;
1465
+ let sql = "SELECT timestamp '1999-01-01 01:23:34'" ;
1469
1466
let select = verified_only_select ( sql) ;
1470
1467
assert_eq ! (
1471
- & Expr :: Cast {
1472
- expr: Box :: new( Expr :: Value ( Value :: SingleQuotedString (
1473
- "1999-01-01 01:23:34" . into( )
1474
- ) ) ) ,
1475
- data_type: DataType :: Timestamp
1468
+ & Expr :: TypedString {
1469
+ data_type: DataType :: Timestamp ,
1470
+ value: "1999-01-01 01:23:34" . into( )
1476
1471
} ,
1477
1472
expr_from_projection( only( & select. projection) ) ,
1478
1473
) ;
0 commit comments