@@ -2181,19 +2181,35 @@ fn parse_pg_regex_match_ops() {
21812181 ] ;
21822182
21832183 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'" ) ) ;
21852186 assert_eq ! (
21862187 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( ) , ) ) ,
21902189 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( ) , ) ) ,
21942191 } ) ,
2195- select. projection[ 0 ]
2192+ select. projection[ 0 ] ,
21962193 ) ;
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+ )
21972213 }
21982214}
21992215
@@ -2207,19 +2223,31 @@ fn parse_pg_like_match_ops() {
22072223 ] ;
22082224
22092225 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%'" ) ) ;
22112228 assert_eq ! (
22122229 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( ) , ) ) ,
22162231 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( ) , ) ) ,
22202233 } ) ,
2221- select. projection[ 0 ]
2234+ select. projection[ 0 ] ,
22222235 ) ;
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+ )
22232251 }
22242252}
22252253
0 commit comments