@@ -11,10 +11,7 @@ mod precedence;
11
11
mod raise_expr;
12
12
mod regexp_match_expr;
13
13
use crate :: parser:: errors:: ParsingError ;
14
- use crate :: {
15
- BinaryOp , Expression , Keyword , LiteralValue , Parser , TokenType , UnaryMatchingExpression ,
16
- UnaryOp ,
17
- } ;
14
+ use crate :: { BinaryOp , Expression , Keyword , LiteralValue , Parser , TokenType , UnaryOp } ;
18
15
use between_expr:: BetweenExpressionParser ;
19
16
use case_expr:: CaseExpressionParser ;
20
17
use cast_expr:: CastExpressionParser ;
@@ -141,27 +138,18 @@ impl ExpressionParser for Parser<'_> {
141
138
return RegexpMatchExpressionParser :: parse_regexp_match_expression ( self , left, false ) ;
142
139
} else if let Ok ( Keyword :: Isnull ) = self . peek_as_keyword ( ) {
143
140
self . consume_as_keyword ( Keyword :: Isnull ) ?;
144
- Ok ( Expression :: UnaryMatchingExpression (
145
- Box :: new ( left) ,
146
- UnaryMatchingExpression :: IsNull ,
147
- ) )
141
+ Ok ( Expression :: IsNull ( Box :: new ( left) ) )
148
142
} else if let Ok ( Keyword :: Notnull ) = self . peek_as_keyword ( ) {
149
143
self . consume_as_keyword ( Keyword :: Notnull ) ?;
150
- Ok ( Expression :: UnaryMatchingExpression (
151
- Box :: new ( left) ,
152
- UnaryMatchingExpression :: IsNotNull ,
153
- ) )
144
+ Ok ( Expression :: IsNotNull ( Box :: new ( left) ) )
154
145
} else if let Ok ( Keyword :: Not ) = self . peek_as_keyword ( ) {
155
146
self . consume_as_keyword ( Keyword :: Not ) ?;
156
147
157
148
if let Ok ( nested_keyword) = self . peek_as_keyword ( ) {
158
149
match nested_keyword {
159
150
Keyword :: Null => {
160
151
self . consume_as_keyword ( Keyword :: Null ) ?;
161
- Ok ( Expression :: UnaryMatchingExpression (
162
- Box :: new ( left) ,
163
- UnaryMatchingExpression :: IsNotNull ,
164
- ) )
152
+ Ok ( Expression :: IsNotNull ( Box :: new ( left) ) )
165
153
}
166
154
Keyword :: Between => {
167
155
BetweenExpressionParser :: parse_between_expression ( self , left, true )
@@ -695,50 +683,31 @@ mod binary_op_tests {
695
683
}
696
684
697
685
#[ cfg( test) ]
698
- mod unary_matching_expression_tests {
686
+ mod null_expression_tests {
699
687
use crate :: parser:: test_utils:: run_sunny_day_test;
700
688
use crate :: select:: test_utils:: select_expr;
701
- use crate :: { Expression , UnaryMatchingExpression } ;
689
+ use crate :: Expression ;
702
690
703
691
use crate :: parser:: expression:: test_utils:: * ;
704
692
705
- fn unary_matching_expression (
706
- expression : Expression ,
707
- unary_matching_expression : UnaryMatchingExpression ,
708
- ) -> Expression {
709
- Expression :: UnaryMatchingExpression ( Box :: new ( expression) , unary_matching_expression)
710
- }
711
-
712
693
#[ test]
713
694
fn isnull ( ) {
714
695
run_sunny_day_test (
715
696
"SELECT 1 ISNULL;" ,
716
- select_expr ( unary_matching_expression (
717
- numeric_expr ( "1" ) ,
718
- UnaryMatchingExpression :: IsNull ,
719
- ) )
720
- . into ( ) ,
697
+ select_expr ( Expression :: IsNull ( Box :: new ( numeric_expr ( "1" ) ) ) ) . into ( ) ,
721
698
) ;
722
699
}
723
700
724
701
#[ test]
725
702
fn notnull ( ) {
726
703
run_sunny_day_test (
727
704
"SELECT 1 NOTNULL;" ,
728
- select_expr ( unary_matching_expression (
729
- numeric_expr ( "1" ) ,
730
- UnaryMatchingExpression :: IsNotNull ,
731
- ) )
732
- . into ( ) ,
705
+ select_expr ( Expression :: IsNotNull ( Box :: new ( numeric_expr ( "1" ) ) ) ) . into ( ) ,
733
706
) ;
734
707
735
708
run_sunny_day_test (
736
709
"SELECT 1 NOT NULL;" ,
737
- select_expr ( unary_matching_expression (
738
- numeric_expr ( "1" ) ,
739
- UnaryMatchingExpression :: IsNotNull ,
740
- ) )
741
- . into ( ) ,
710
+ select_expr ( Expression :: IsNotNull ( Box :: new ( numeric_expr ( "1" ) ) ) ) . into ( ) ,
742
711
) ;
743
712
}
744
713
}
0 commit comments