ilike multibyte fix for postgres 8.1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--- django/db/backends/postgresql_psycopg2/base.py.0    2007-10-30 10:13:56.000000000 +0100
+++ django/db/backends/postgresql_psycopg2/base.py  2007-10-30 10:22:16.000000000 +0100
@@ -20,6 +20,7 @@

 class DatabaseFeatures(BaseDatabaseFeatures):
     needs_datetime_string_cast = False
+    needs_upper_for_iops = True

 class DatabaseOperations(PostgresqlDatabaseOperations):
     def last_executed_query(self, cursor, sql, params):
@@ -33,9 +34,9 @@
     ops = DatabaseOperations()
     operators = {
         'exact': '= %s',
-        'iexact': 'ILIKE %s',
+        'iexact': 'LIKE UPPER(%s)',
         'contains': 'LIKE %s',
-        'icontains': 'ILIKE %s',
+        'icontains': 'LIKE UPPER(%s)',
         'regex': '~ %s',
         'iregex': '~* %s',
         'gt': '> %s',
@@ -44,8 +45,8 @@
         'lte': '<= %s',
         'startswith': 'LIKE %s',
         'endswith': 'LIKE %s',
-        'istartswith': 'ILIKE %s',
-        'iendswith': 'ILIKE %s',
+        'istartswith': 'LIKE UPPER(%s)',
+        'iendswith': 'LIKE UPPER(%s)',
     }

     def _cursor(self, settings):

Comments

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.