@@ -793,7 +793,7 @@ fn parse_not_precedence() {
793
793
expr: Box :: new( Expr :: Like {
794
794
expr: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "a" . into( ) ) ) ) ,
795
795
negated: true ,
796
- pattern: Box :: new( Value :: SingleQuotedString ( "b" . into( ) ) ) ,
796
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "b" . into( ) ) ) ) ,
797
797
escape_char: None
798
798
} ) ,
799
799
} ,
@@ -826,7 +826,7 @@ fn parse_like() {
826
826
Expr :: Like {
827
827
expr: Box :: new( Expr :: Identifier ( Ident :: new( "name" ) ) ) ,
828
828
negated,
829
- pattern: Box :: new( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ,
829
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ) ,
830
830
escape_char: None
831
831
} ,
832
832
select. selection. unwrap( )
@@ -842,7 +842,7 @@ fn parse_like() {
842
842
Expr :: Like {
843
843
expr: Box :: new( Expr :: Identifier ( Ident :: new( "name" ) ) ) ,
844
844
negated,
845
- pattern: Box :: new( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ,
845
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ) ,
846
846
escape_char: Some ( '\\' )
847
847
} ,
848
848
select. selection. unwrap( )
@@ -859,7 +859,7 @@ fn parse_like() {
859
859
Expr :: IsNull ( Box :: new( Expr :: Like {
860
860
expr: Box :: new( Expr :: Identifier ( Ident :: new( "name" ) ) ) ,
861
861
negated,
862
- pattern: Box :: new( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ,
862
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ) ,
863
863
escape_char: None
864
864
} ) ) ,
865
865
select. selection. unwrap( )
@@ -869,6 +869,45 @@ fn parse_like() {
869
869
chk ( true ) ;
870
870
}
871
871
872
+ #[ test]
873
+ fn parse_null_like ( ) {
874
+ let sql = "SELECT \
875
+ column1 LIKE NULL AS col_null, \
876
+ NULL LIKE column1 AS null_col \
877
+ FROM customers";
878
+ let select = verified_only_select ( sql) ;
879
+ assert_eq ! (
880
+ SelectItem :: ExprWithAlias {
881
+ expr: Expr :: Like {
882
+ expr: Box :: new( Expr :: Identifier ( Ident :: new( "column1" ) ) ) ,
883
+ negated: false ,
884
+ pattern: Box :: new( Expr :: Value ( Value :: Null ) ) ,
885
+ escape_char: None
886
+ } ,
887
+ alias: Ident {
888
+ value: "col_null" . to_owned( ) ,
889
+ quote_style: None
890
+ }
891
+ } ,
892
+ select. projection[ 0 ]
893
+ ) ;
894
+ assert_eq ! (
895
+ SelectItem :: ExprWithAlias {
896
+ expr: Expr :: Like {
897
+ expr: Box :: new( Expr :: Value ( Value :: Null ) ) ,
898
+ negated: false ,
899
+ pattern: Box :: new( Expr :: Identifier ( Ident :: new( "column1" ) ) ) ,
900
+ escape_char: None
901
+ } ,
902
+ alias: Ident {
903
+ value: "null_col" . to_owned( ) ,
904
+ quote_style: None
905
+ }
906
+ } ,
907
+ select. projection[ 1 ]
908
+ ) ;
909
+ }
910
+
872
911
#[ test]
873
912
fn parse_ilike ( ) {
874
913
fn chk ( negated : bool ) {
@@ -881,7 +920,7 @@ fn parse_ilike() {
881
920
Expr :: ILike {
882
921
expr: Box :: new( Expr :: Identifier ( Ident :: new( "name" ) ) ) ,
883
922
negated,
884
- pattern: Box :: new( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ,
923
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ) ,
885
924
escape_char: None
886
925
} ,
887
926
select. selection. unwrap( )
@@ -897,7 +936,7 @@ fn parse_ilike() {
897
936
Expr :: ILike {
898
937
expr: Box :: new( Expr :: Identifier ( Ident :: new( "name" ) ) ) ,
899
938
negated,
900
- pattern: Box :: new( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ,
939
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ) ,
901
940
escape_char: Some ( '^' )
902
941
} ,
903
942
select. selection. unwrap( )
@@ -914,7 +953,7 @@ fn parse_ilike() {
914
953
Expr :: IsNull ( Box :: new( Expr :: ILike {
915
954
expr: Box :: new( Expr :: Identifier ( Ident :: new( "name" ) ) ) ,
916
955
negated,
917
- pattern: Box :: new( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ,
956
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ) ,
918
957
escape_char: None
919
958
} ) ) ,
920
959
select. selection. unwrap( )
@@ -936,7 +975,7 @@ fn parse_similar_to() {
936
975
Expr :: SimilarTo {
937
976
expr: Box :: new( Expr :: Identifier ( Ident :: new( "name" ) ) ) ,
938
977
negated,
939
- pattern: Box :: new( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ,
978
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ) ,
940
979
escape_char: None
941
980
} ,
942
981
select. selection. unwrap( )
@@ -952,7 +991,7 @@ fn parse_similar_to() {
952
991
Expr :: SimilarTo {
953
992
expr: Box :: new( Expr :: Identifier ( Ident :: new( "name" ) ) ) ,
954
993
negated,
955
- pattern: Box :: new( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ,
994
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ) ,
956
995
escape_char: Some ( '\\' )
957
996
} ,
958
997
select. selection. unwrap( )
@@ -968,7 +1007,7 @@ fn parse_similar_to() {
968
1007
Expr :: IsNull ( Box :: new( Expr :: SimilarTo {
969
1008
expr: Box :: new( Expr :: Identifier ( Ident :: new( "name" ) ) ) ,
970
1009
negated,
971
- pattern: Box :: new( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ,
1010
+ pattern: Box :: new( Expr :: Value ( Value :: SingleQuotedString ( "%a" . to_string( ) ) ) ) ,
972
1011
escape_char: Some ( '\\' )
973
1012
} ) ) ,
974
1013
select. selection. unwrap( )
0 commit comments