@@ -2181,19 +2181,35 @@ fn parse_pg_regex_match_ops() {
2181
2181
] ;
2182
2182
2183
2183
for ( str_op, op) in pg_regex_match_ops {
2184
- let select = pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {} '^a'" , & str_op) ) ;
2184
+ // Basic binary operation usage
2185
+ let select = pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {str_op} '^a'" ) ) ;
2185
2186
assert_eq ! (
2186
2187
SelectItem :: UnnamedExpr ( Expr :: BinaryOp {
2187
- left: Box :: new( Expr :: Value (
2188
- ( Value :: SingleQuotedString ( "abc" . into( ) ) ) . with_empty_span( )
2189
- ) ) ,
2188
+ left: Box :: new( Expr :: Value ( single_quoted_string( "abc" ) . with_empty_span( ) , ) ) ,
2190
2189
op: op. clone( ) ,
2191
- right: Box :: new( Expr :: Value (
2192
- ( Value :: SingleQuotedString ( "^a" . into( ) ) ) . with_empty_span( )
2193
- ) ) ,
2190
+ right: Box :: new( Expr :: Value ( single_quoted_string( "^a" ) . with_empty_span( ) , ) ) ,
2194
2191
} ) ,
2195
- select. projection[ 0 ]
2192
+ select. projection[ 0 ] ,
2196
2193
) ;
2194
+
2195
+ // Binary operator with ANY operator
2196
+ let select =
2197
+ pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {str_op} ANY(ARRAY['^a', 'x'])" ) ) ;
2198
+ assert_eq ! (
2199
+ SelectItem :: UnnamedExpr ( Expr :: AnyOp {
2200
+ left: Box :: new( Expr :: Value ( single_quoted_string( "abc" ) . with_empty_span( ) , ) ) ,
2201
+ compare_op: op. clone( ) ,
2202
+ right: Box :: new( Expr :: Array ( Array {
2203
+ elem: vec![
2204
+ Expr :: Value ( single_quoted_string( "^a" ) . with_empty_span( ) ) ,
2205
+ Expr :: Value ( single_quoted_string( "x" ) . with_empty_span( ) ) ,
2206
+ ] ,
2207
+ named: true ,
2208
+ } ) ) ,
2209
+ is_some: false ,
2210
+ } ) ,
2211
+ select. projection[ 0 ] ,
2212
+ )
2197
2213
}
2198
2214
}
2199
2215
@@ -2207,19 +2223,31 @@ fn parse_pg_like_match_ops() {
2207
2223
] ;
2208
2224
2209
2225
for ( str_op, op) in pg_like_match_ops {
2210
- let select = pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {} 'a_c%'" , & str_op) ) ;
2226
+ // Basic binary operation usage
2227
+ let select = pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {str_op} 'a_c%'" ) ) ;
2211
2228
assert_eq ! (
2212
2229
SelectItem :: UnnamedExpr ( Expr :: BinaryOp {
2213
- left: Box :: new( Expr :: Value (
2214
- ( Value :: SingleQuotedString ( "abc" . into( ) ) ) . with_empty_span( )
2215
- ) ) ,
2230
+ left: Box :: new( Expr :: Value ( single_quoted_string( "abc" ) . with_empty_span( ) , ) ) ,
2216
2231
op: op. clone( ) ,
2217
- right: Box :: new( Expr :: Value (
2218
- ( Value :: SingleQuotedString ( "a_c%" . into( ) ) ) . with_empty_span( )
2219
- ) ) ,
2232
+ right: Box :: new( Expr :: Value ( single_quoted_string( "a_c%" ) . with_empty_span( ) , ) ) ,
2220
2233
} ) ,
2221
- select. projection[ 0 ]
2234
+ select. projection[ 0 ] ,
2222
2235
) ;
2236
+
2237
+ // Binary operator with ALL operator
2238
+ let select =
2239
+ pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {str_op} ALL(ARRAY['a_c%'])" ) ) ;
2240
+ assert_eq ! (
2241
+ SelectItem :: UnnamedExpr ( Expr :: AllOp {
2242
+ left: Box :: new( Expr :: Value ( single_quoted_string( "abc" ) . with_empty_span( ) , ) ) ,
2243
+ compare_op: op. clone( ) ,
2244
+ right: Box :: new( Expr :: Array ( Array {
2245
+ elem: vec![ Expr :: Value ( single_quoted_string( "a_c%" ) . with_empty_span( ) ) ] ,
2246
+ named: true ,
2247
+ } ) ) ,
2248
+ } ) ,
2249
+ select. projection[ 0 ] ,
2250
+ )
2223
2251
}
2224
2252
}
2225
2253
0 commit comments