Ticket #17473: patch.r17282

File patch.r17282, 4.7 KB (added by Pablo Martín, 12 years ago)
Line 
1Index: db/models/sql/constants.py
2===================================================================
3--- db/models/sql/constants.py (revisión: 17282)
4+++ db/models/sql/constants.py (copia de trabajo)
5@@ -5,6 +5,7 @@
6 'exact', 'iexact', 'contains', 'icontains', 'gt', 'gte', 'lt', 'lte', 'in',
7 'startswith', 'istartswith', 'endswith', 'iendswith', 'range', 'year',
8 'month', 'day', 'week_day', 'isnull', 'search', 'regex', 'iregex',
9+ 'like', 'ilike',
10 )])
11
12 # Size of each "chunk" for get_iterator calls.
13Index: db/models/fields/__init__.py
14===================================================================
15--- db/models/fields/__init__.py (revisión: 17282)
16+++ db/models/fields/__init__.py (copia de trabajo)
17@@ -303,7 +303,7 @@
18 if lookup_type in (
19 'regex', 'iregex', 'month', 'day', 'week_day', 'search',
20 'contains', 'icontains', 'iexact', 'startswith', 'istartswith',
21- 'endswith', 'iendswith', 'isnull'
22+ 'endswith', 'iendswith', 'isnull', 'ilike', 'like',
23 ):
24 return value
25 elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'):
26@@ -340,7 +340,7 @@
27 return QueryWrapper(('(%s)' % sql), params)
28
29 if lookup_type in ('regex', 'iregex', 'month', 'day', 'week_day',
30- 'search'):
31+ 'search', 'like', 'ilike'):
32 return [value]
33 elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'):
34 return [self.get_db_prep_value(value, connection=connection,
35Index: db/backends/sqlite3/base.py
36===================================================================
37--- db/backends/sqlite3/base.py (revisión: 17282)
38+++ db/backends/sqlite3/base.py (copia de trabajo)
39@@ -218,6 +218,8 @@
40 'endswith': "LIKE %s ESCAPE '\\'",
41 'istartswith': "LIKE %s ESCAPE '\\'",
42 'iendswith': "LIKE %s ESCAPE '\\'",
43+ 'like': "LIKE %s ESCAPE '\\'",
44+ 'ilike': "LIKE %s ESCAPE '\\'",
45 }
46
47 def __init__(self, *args, **kwargs):
48Index: db/backends/mysql/base.py
49===================================================================
50--- db/backends/mysql/base.py (revisión: 17282)
51+++ db/backends/mysql/base.py (copia de trabajo)
52@@ -302,6 +302,8 @@
53 'endswith': 'LIKE BINARY %s',
54 'istartswith': 'LIKE %s',
55 'iendswith': 'LIKE %s',
56+ 'like': 'LIKE BINARY %s',
57+ 'ilike': 'LIKE %s',
58 }
59
60 def __init__(self, *args, **kwargs):
61Index: db/backends/oracle/base.py
62===================================================================
63--- db/backends/oracle/base.py (revisión: 17282)
64+++ db/backends/oracle/base.py (copia de trabajo)
65@@ -218,7 +218,8 @@
66 return cursor.fetchone()[0]
67
68 def lookup_cast(self, lookup_type):
69- if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith'):
70+ if lookup_type in ('iexact', 'icontains',
71+ 'istartswith', 'iendswith', 'ilike'):
72 return "UPPER(%s)"
73 return "%s"
74
75@@ -419,6 +420,8 @@
76 'endswith': "LIKE TRANSLATE(%s USING NCHAR_CS) ESCAPE TRANSLATE('\\' USING NCHAR_CS)",
77 'istartswith': "LIKE UPPER(TRANSLATE(%s USING NCHAR_CS)) ESCAPE TRANSLATE('\\' USING NCHAR_CS)",
78 'iendswith': "LIKE UPPER(TRANSLATE(%s USING NCHAR_CS)) ESCAPE TRANSLATE('\\' USING NCHAR_CS)",
79+ 'like': "LIKE TRANSLATE(%s USING NCHAR_CS) ESCAPE TRANSLATE('\\' USING NCHAR_CS)",
80+ 'ilike': "LIKE UPPER(TRANSLATE(%s USING NCHAR_CS)) ESCAPE TRANSLATE('\\' USING NCHAR_CS)",
81 }
82
83 _likec_operators = _standard_operators.copy()
84Index: db/backends/postgresql_psycopg2/base.py
85===================================================================
86--- db/backends/postgresql_psycopg2/base.py (revisión: 17282)
87+++ db/backends/postgresql_psycopg2/base.py (copia de trabajo)
88@@ -101,6 +101,8 @@
89 'endswith': 'LIKE %s',
90 'istartswith': 'LIKE UPPER(%s)',
91 'iendswith': 'LIKE UPPER(%s)',
92+ 'like': 'LIKE %s',
93+ 'ilike': 'LIKE UPPER(%s)',
94 }
95
96 def __init__(self, *args, **kwargs):
97Index: db/backends/postgresql_psycopg2/operations.py
98===================================================================
99--- db/backends/postgresql_psycopg2/operations.py (revisión: 17282)
100+++ db/backends/postgresql_psycopg2/operations.py (copia de trabajo)
101@@ -46,7 +46,8 @@
102 lookup = "%s::text"
103
104 # Use UPPER(x) for case-insensitive lookups; it's faster.
105- if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith'):
106+ if lookup_type in ('iexact', 'icontains',
107+ 'istartswith', 'iendswith', 'ilike'):
108 lookup = 'UPPER(%s)' % lookup
109
110 return lookup
Back to Top