1
1
use crate :: parser:: errors:: ParsingError ;
2
- use crate :: { AnIsExpression , BinaryMatchingExpression , Expression , Keyword , Parser } ;
2
+ use crate :: { AnIsExpression , Expression , Keyword , Parser } ;
3
3
4
4
use super :: ExpressionParser ;
5
5
@@ -22,58 +22,44 @@ impl IsExpressionParser for Parser<'_> {
22
22
self . consume_as_keyword ( Keyword :: From ) ?;
23
23
}
24
24
25
- let is_expression = BinaryMatchingExpression :: Is ( AnIsExpression {
26
- expression : Box :: new ( self . parse_expression ( ) ?) ,
25
+ let is_expression = AnIsExpression {
26
+ expression : Box :: new ( expression) ,
27
+ not : is_not,
27
28
distinct,
28
- } ) ;
29
-
30
- let result = if is_not {
31
- BinaryMatchingExpression :: Not ( Box :: new ( is_expression) )
32
- } else {
33
- is_expression
29
+ matching_expression : Box :: new ( self . parse_expression ( ) ?) ,
34
30
} ;
35
31
36
- Ok ( Expression :: BinaryMatchingExpression (
37
- Box :: new ( expression) ,
38
- result,
39
- ) )
32
+ Ok ( Expression :: IsExpression ( is_expression) )
40
33
}
41
34
}
42
35
43
36
#[ cfg( test) ]
44
37
mod is_expression_tests {
45
38
use crate :: parser:: test_utils:: run_sunny_day_test;
46
39
use crate :: select:: test_utils:: select_expr;
47
- use crate :: { AnIsExpression , BinaryMatchingExpression , Expression } ;
40
+ use crate :: { AnIsExpression , Expression } ;
48
41
49
42
use crate :: parser:: expression:: test_utils:: * ;
50
43
51
- fn expr_from_expr (
44
+ fn is_expression (
52
45
expression : Expression ,
53
- is_expression : Expression ,
46
+ matching_expression : Expression ,
54
47
distinct : bool ,
55
48
is_not : bool ,
56
49
) -> Expression {
57
- let binary_matching_expression = if is_not {
58
- BinaryMatchingExpression :: Not ( Box :: new ( BinaryMatchingExpression :: Is ( AnIsExpression {
59
- expression : Box :: new ( is_expression) ,
60
- distinct,
61
- } ) ) )
62
- } else {
63
- BinaryMatchingExpression :: Is ( AnIsExpression {
64
- expression : Box :: new ( is_expression) ,
65
- distinct,
66
- } )
67
- } ;
68
-
69
- Expression :: BinaryMatchingExpression ( Box :: new ( expression) , binary_matching_expression)
50
+ Expression :: IsExpression ( AnIsExpression {
51
+ expression : Box :: new ( expression) ,
52
+ distinct,
53
+ not : is_not,
54
+ matching_expression : Box :: new ( matching_expression) ,
55
+ } )
70
56
}
71
57
72
58
#[ test]
73
59
fn is_expr_test ( ) {
74
60
run_sunny_day_test (
75
61
"SELECT 1 IS 1;" ,
76
- select_expr ( expr_from_expr (
62
+ select_expr ( is_expression (
77
63
numeric_expr ( "1" ) ,
78
64
numeric_expr ( "1" ) ,
79
65
false ,
@@ -87,7 +73,7 @@ mod is_expression_tests {
87
73
fn is_not_expr_test ( ) {
88
74
run_sunny_day_test (
89
75
"SELECT 1 IS NOT 1;" ,
90
- select_expr ( expr_from_expr (
76
+ select_expr ( is_expression (
91
77
numeric_expr ( "1" ) ,
92
78
numeric_expr ( "1" ) ,
93
79
false ,
@@ -101,7 +87,7 @@ mod is_expression_tests {
101
87
fn is_distinct_expr_test ( ) {
102
88
run_sunny_day_test (
103
89
"SELECT 1 IS DISTINCT FROM 1;" ,
104
- select_expr ( expr_from_expr (
90
+ select_expr ( is_expression (
105
91
numeric_expr ( "1" ) ,
106
92
numeric_expr ( "1" ) ,
107
93
true ,
0 commit comments