@@ -2187,21 +2187,39 @@ fn parse_pg_regex_match_ops() {
2187
2187
( "!~*" , BinaryOperator :: PGRegexNotIMatch ) ,
2188
2188
] ;
2189
2189
2190
+ // Match against a single value
2190
2191
for ( str_op, op) in pg_regex_match_ops {
2191
- let select = pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {} '^a'" , & str_op ) ) ;
2192
+ let select = pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {str_op } '^a'" ) ) ;
2192
2193
assert_eq ! (
2193
2194
SelectItem :: UnnamedExpr ( Expr :: BinaryOp {
2194
- left: Box :: new( Expr :: Value (
2195
- ( Value :: SingleQuotedString ( "abc" . into( ) ) ) . with_empty_span( )
2196
- ) ) ,
2195
+ left: Box :: new( Expr :: Value ( single_quoted_string( "abc" ) . with_empty_span( ) , ) ) ,
2197
2196
op: op. clone( ) ,
2198
- right: Box :: new( Expr :: Value (
2199
- ( Value :: SingleQuotedString ( "^a" . into( ) ) ) . with_empty_span( )
2200
- ) ) ,
2197
+ right: Box :: new( Expr :: Value ( single_quoted_string( "^a" ) . with_empty_span( ) , ) ) ,
2201
2198
} ) ,
2202
2199
select. projection[ 0 ]
2203
2200
) ;
2204
2201
}
2202
+
2203
+ // Match against any value from an array
2204
+ for ( str_op, op) in pg_regex_match_ops {
2205
+ let select =
2206
+ pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {str_op} ANY(ARRAY['^a', 'x'])" ) ) ;
2207
+ assert_eq ! (
2208
+ SelectItem :: UnnamedExpr ( Expr :: AnyOp {
2209
+ left: Box :: new( Expr :: Value ( single_quoted_string( "abc" ) . with_empty_span( ) , ) ) ,
2210
+ compare_op: op. clone( ) ,
2211
+ right: Box :: new( Expr :: Array ( Array {
2212
+ elem: vec![
2213
+ Expr :: Value ( single_quoted_string( "^a" ) . with_empty_span( ) ) ,
2214
+ Expr :: Value ( single_quoted_string( "x" ) . with_empty_span( ) ) ,
2215
+ ] ,
2216
+ named: true ,
2217
+ } ) ) ,
2218
+ is_some: false ,
2219
+ } ) ,
2220
+ select. projection[ 0 ]
2221
+ )
2222
+ }
2205
2223
}
2206
2224
2207
2225
#[ test]
@@ -2213,21 +2231,35 @@ fn parse_pg_like_match_ops() {
2213
2231
( "!~~*" , BinaryOperator :: PGNotILikeMatch ) ,
2214
2232
] ;
2215
2233
2234
+ // Match against a single value
2216
2235
for ( str_op, op) in pg_like_match_ops {
2217
- let select = pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {} 'a_c%'" , & str_op ) ) ;
2236
+ let select = pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {str_op } 'a_c%'" ) ) ;
2218
2237
assert_eq ! (
2219
2238
SelectItem :: UnnamedExpr ( Expr :: BinaryOp {
2220
- left: Box :: new( Expr :: Value (
2221
- ( Value :: SingleQuotedString ( "abc" . into( ) ) ) . with_empty_span( )
2222
- ) ) ,
2239
+ left: Box :: new( Expr :: Value ( single_quoted_string( "abc" ) . with_empty_span( ) , ) ) ,
2223
2240
op: op. clone( ) ,
2224
- right: Box :: new( Expr :: Value (
2225
- ( Value :: SingleQuotedString ( "a_c%" . into( ) ) ) . with_empty_span( )
2226
- ) ) ,
2241
+ right: Box :: new( Expr :: Value ( single_quoted_string( "a_c%" ) . with_empty_span( ) , ) ) ,
2227
2242
} ) ,
2228
2243
select. projection[ 0 ]
2229
2244
) ;
2230
2245
}
2246
+
2247
+ // Match against all values from an array
2248
+ for ( str_op, op) in pg_like_match_ops {
2249
+ let select =
2250
+ pg ( ) . verified_only_select ( & format ! ( "SELECT 'abc' {str_op} ALL(ARRAY['a_c%'])" ) ) ;
2251
+ assert_eq ! (
2252
+ SelectItem :: UnnamedExpr ( Expr :: AllOp {
2253
+ left: Box :: new( Expr :: Value ( single_quoted_string( "abc" ) . with_empty_span( ) , ) ) ,
2254
+ compare_op: op. clone( ) ,
2255
+ right: Box :: new( Expr :: Array ( Array {
2256
+ elem: vec![ Expr :: Value ( single_quoted_string( "a_c%" ) . with_empty_span( ) ) ] ,
2257
+ named: true ,
2258
+ } ) ) ,
2259
+ } ) ,
2260
+ select. projection[ 0 ]
2261
+ )
2262
+ }
2231
2263
}
2232
2264
2233
2265
#[ test]
0 commit comments