@@ -76,6 +76,26 @@ class DatabaseWrapper(BaseDatabaseWrapper):
76
76
features = DatabaseFeatures ()
77
77
ops = DatabaseOperations ()
78
78
79
+ # SQLite requires LIKE statements to include an ESCAPE clause if the value
80
+ # being escaped has a percent or underscore in it.
81
+ # See http://www.sqlite.org/lang_expr.html for an explanation.
82
+ operators = {
83
+ 'exact' : '= %s' ,
84
+ 'iexact' : "LIKE %s ESCAPE '\\ '" ,
85
+ 'contains' : "LIKE %s ESCAPE '\\ '" ,
86
+ 'icontains' : "LIKE %s ESCAPE '\\ '" ,
87
+ 'regex' : 'REGEXP %s' ,
88
+ 'iregex' : "REGEXP '(?i)' || %s" ,
89
+ 'gt' : '> %s' ,
90
+ 'gte' : '>= %s' ,
91
+ 'lt' : '< %s' ,
92
+ 'lte' : '<= %s' ,
93
+ 'startswith' : "LIKE %s ESCAPE '\\ '" ,
94
+ 'endswith' : "LIKE %s ESCAPE '\\ '" ,
95
+ 'istartswith' : "LIKE %s ESCAPE '\\ '" ,
96
+ 'iendswith' : "LIKE %s ESCAPE '\\ '" ,
97
+ }
98
+
79
99
def _cursor (self , settings ):
80
100
if self .connection is None :
81
101
kwargs = {
@@ -140,24 +160,3 @@ def _sqlite_regexp(re_pattern, re_string):
140
160
return bool (re .search (re_pattern , re_string ))
141
161
except :
142
162
return False
143
-
144
- # SQLite requires LIKE statements to include an ESCAPE clause if the value
145
- # being escaped has a percent or underscore in it.
146
- # See http://www.sqlite.org/lang_expr.html for an explanation.
147
- OPERATOR_MAPPING = {
148
- 'exact' : '= %s' ,
149
- 'iexact' : "LIKE %s ESCAPE '\\ '" ,
150
- 'contains' : "LIKE %s ESCAPE '\\ '" ,
151
- 'icontains' : "LIKE %s ESCAPE '\\ '" ,
152
- 'regex' : 'REGEXP %s' ,
153
- 'iregex' : "REGEXP '(?i)' || %s" ,
154
- 'gt' : '> %s' ,
155
- 'gte' : '>= %s' ,
156
- 'lt' : '< %s' ,
157
- 'lte' : '<= %s' ,
158
- 'startswith' : "LIKE %s ESCAPE '\\ '" ,
159
- 'endswith' : "LIKE %s ESCAPE '\\ '" ,
160
- 'istartswith' : "LIKE %s ESCAPE '\\ '" ,
161
- 'iendswith' : "LIKE %s ESCAPE '\\ '" ,
162
- }
163
-
0 commit comments