]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fixed NOT ILIKE
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Jan 2008 21:30:02 +0000 (21:30 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Jan 2008 21:30:02 +0000 (21:30 +0000)
lib/sqlalchemy/databases/postgres.py
lib/sqlalchemy/sql/compiler.py
test/sql/select.py

index bab998d6978b39a3db2d9f81c180b4a1b888d18e..220c2a487a6b5d658d5204e35018b289bb707190 100644 (file)
@@ -626,7 +626,8 @@ class PGCompiler(compiler.DefaultCompiler):
     operators.update(
         {
             sql_operators.mod : '%%',
-            sql_operators.ilike_op: 'ILIKE'
+            sql_operators.ilike_op: 'ILIKE',
+            sql_operators.notilike_op: 'NOT ILIKE'
         }
     )
 
index 545c0a1b4270d74e2378a4428ed73bdf7a543c47..8f2e3372a3a257c91ffeed0049412102e6f1db78 100644 (file)
@@ -80,7 +80,7 @@ OPERATORS =  {
     operators.like_op : 'LIKE',
     operators.notlike_op : 'NOT LIKE',
     operators.ilike_op : lambda x, y: "lower(%s) LIKE lower(%s)" % (x, y),
-    operators.notilike_op : 'NOT ILIKE',
+    operators.notilike_op : lambda x, y: "lower(%s) NOT LIKE lower(%s)" % (x, y),
     operators.between_op : 'BETWEEN',
     operators.in_op : 'IN',
     operators.notin_op : 'NOT IN',
index b922c5c22ca8cac8d57b5740ed2c60a2f9dadea0..4c15bfb1b803105943d50ea7b40212f1da9e6940 100644 (file)
@@ -527,9 +527,13 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A
 
     def testilike(self):
         stmt = table1.select(table1.c.name.ilike('%something%'))
-        self.assert_compile(stmt, "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE lower(mytable.name) LIKE :mytable_name_1")
+        self.assert_compile(stmt, "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE lower(mytable.name) LIKE lower(:mytable_name_1)")
         self.assert_compile(stmt, "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.name ILIKE %(mytable_name_1)s", dialect=postgres.PGDialect())
 
+        stmt = table1.select(~table1.c.name.ilike('%something%'))
+        self.assert_compile(stmt, "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE lower(mytable.name) NOT LIKE lower(:mytable_name_1)")
+        self.assert_compile(stmt, "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.name NOT ILIKE %(mytable_name_1)s", dialect=postgres.PGDialect())
+
     def testforupdate(self):
         self.assert_compile(table1.select(table1.c.myid==7, for_update=True), "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.myid = :mytable_myid_1 FOR UPDATE")