File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3725,6 +3725,18 @@ def neg_sql(self, expression: exp.Neg) -> str:
37253725 return f"-{ sep } { this_sql } "
37263726
37273727 def not_sql (self , expression : exp .Not ) -> str :
3728+ this = expression .this
3729+ if (
3730+ isinstance (this , (exp .Like , exp .ILike ))
3731+ and isinstance (this .expression , (exp .All , exp .Any ))
3732+ and self .SUPPORTS_LIKE_QUANTIFIERS
3733+ ):
3734+ op = "ILIKE" if isinstance (this , exp .ILike ) else "LIKE"
3735+ quantifier = "ALL" if isinstance (this .expression , exp .All ) else "ANY"
3736+ return (
3737+ f"{ self .sql (this , 'this' )} "
3738+ f"NOT { op } { quantifier } { self .sql (this .expression , 'this' )} "
3739+ )
37283740 return f"NOT { self .sql (expression , 'this' )} "
37293741
37303742 def alias_sql (self , expression : exp .Alias ) -> str :
Original file line number Diff line number Diff line change @@ -267,6 +267,20 @@ def test_postgres(self):
267267 "x !~~* 'y'" ,
268268 "NOT x ILIKE 'y'" ,
269269 )
270+ self .validate_identity ("SELECT 'testa 1' NOT LIKE ALL (ARRAY['testa%', 'testb%'])" )
271+ self .validate_identity ("SELECT 'testa 1' NOT LIKE ANY (ARRAY['testa%', 'testb%'])" )
272+ self .validate_identity ("SELECT 'testa 1' NOT ILIKE ALL (ARRAY['testa%', 'testb%'])" )
273+ self .validate_identity ("SELECT 'testa 1' NOT ILIKE ANY (ARRAY['testa%', 'testb%'])" )
274+ self .validate_identity ("SELECT NOT ('testa 1' LIKE ALL (ARRAY['testa%', 'testb%']))" )
275+ self .validate_identity (
276+ "SELECT NOT ('testa 1' LIKE ANY (ARRAY['testa%', 'testb%']))" ,
277+ "SELECT NOT ('testa 1' LIKE ANY(ARRAY['testa%', 'testb%']))" ,
278+ )
279+ self .validate_identity ("SELECT NOT ('testa 1' ILIKE ALL (ARRAY['testa%', 'testb%']))" )
280+ self .validate_identity (
281+ "SELECT NOT ('testa 1' ILIKE ANY (ARRAY['testa%', 'testb%']))" ,
282+ "SELECT NOT ('testa 1' ILIKE ANY(ARRAY['testa%', 'testb%']))" ,
283+ )
270284 self .validate_identity (
271285 "'45 days'::interval day" ,
272286 "CAST('45 days' AS INTERVAL DAY)" ,
You can’t perform that action at this time.
0 commit comments