Commits

Waldemar Kornewald committed 5f55242

fixed SQLQuery.as_sql() support

  • Participants
  • Parent commits baf3bbf

Comments (0)

Files changed (1)

File djangotoolbox/db/base.py

         raise NotImplementedError('Cursors not supported')
 
 class NonrelDatabaseWrapper(BaseDatabaseWrapper):
+    # These fake operators are required for SQLQuery.as_sql() support.
+    operators = {
+        'exact': '= %s',
+        'iexact': '= UPPER(%s)',
+        'contains': 'LIKE %s',
+        'icontains': 'LIKE UPPER(%s)',
+        'regex': '~ %s',
+        'iregex': '~* %s',
+        'gt': '> %s',
+        'gte': '>= %s',
+        'lt': '< %s',
+        'lte': '<= %s',
+        'startswith': 'LIKE %s',
+        'endswith': 'LIKE %s',
+        'istartswith': 'LIKE UPPER(%s)',
+        'iendswith': 'LIKE UPPER(%s)',
+    }
+
     def _cursor(self):
         return FakeCursor()