summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-23 07:30:59 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-23 07:30:59 +0000
commit382d31a981a6682484e2f8346b939429588cb562 (patch)
tree9d7799e4653adf1c32111d4c6f9f8ea6f8ede7f0
parent5a9a208b7a72a1ce6b73ac4bbc93b8468da1b891 (diff)
queryset-refactor: Fixed some errors in Oracle regex handling that were
introduced in [7087]. Patch from Ian Kelly. Fixed #7065. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7444 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/backends/oracle/base.py13
-rw-r--r--django/db/models/sql/where.py2
2 files changed, 11 insertions, 4 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 9b0dbf1beb..3635acdf2a 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -119,10 +119,17 @@ class DatabaseOperations(BaseDatabaseOperations):
def regex_lookup_10(self, lookup_type):
if lookup_type == 'regex':
- match_option = 'c'
+ match_option = "'c'"
else:
- match_option = 'i'
- return 'REGEXP_LIKE(%%s %%s %s)' % match_option
+ match_option = "'i'"
+ return 'REGEXP_LIKE(%%s, %%s, %s)' % match_option
+
+ def regex_lookup(self, lookup_type):
+ # If regex_lookup is called before it's been initialized, then create
+ # a cursor to initialize it and recur.
+ from django.db import connection
+ connection.cursor()
+ return connection.ops.regex_lookup(lookup_type)
def sql_flush(self, style, tables, sequences):
# Return a list of 'TRUNCATE x;', 'TRUNCATE y;',
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 59607d5534..3e11fa53c0 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -140,7 +140,7 @@ class WhereNode(tree.Node):
elif lookup_type == 'search':
return (connection.ops.fulltext_search_sql(field_sql), params)
elif lookup_type in ('regex', 'iregex'):
- return connection.ops.regex_lookup % (field_sql, cast_sql), params
+ return connection.ops.regex_lookup(lookup_type) % (field_sql, cast_sql), params
raise TypeError('Invalid lookup_type: %r' % lookup_type)