diff options
| author | Matt Boersma <matt@sprout.org> | 2007-09-14 18:26:07 +0000 |
|---|---|---|
| committer | Matt Boersma <matt@sprout.org> | 2007-09-14 18:26:07 +0000 |
| commit | a6b1d65e33d3ff44fd81f6497e812f89f9c3d9e0 (patch) | |
| tree | 0ee73ca16ac972f8fc906571ee1688890eef7e10 | |
| parent | 55d34c6cb37fd7459634849a232ed225d90e4583 (diff) | |
Fixed #5226. Now we check the Oracle version and give an explicit
error when we encounter a regex operator that isn't supported on 9i or
earlier.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6198 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/db/backends/oracle/base.py | 5 | ||||
| -rw-r--r-- | django/db/models/query.py | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 4093b69be6..76e5743539 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -400,6 +400,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): 'istartswith': "LIKE UPPER(%s) ESCAPE '\\'", 'iendswith': "LIKE UPPER(%s) ESCAPE '\\'", } + oracle_version = None def _valid_connection(self): return self.connection is not None @@ -414,6 +415,10 @@ class DatabaseWrapper(BaseDatabaseWrapper): else: conn_string = "%s/%s@%s" % (settings.DATABASE_USER, settings.DATABASE_PASSWORD, settings.DATABASE_NAME) self.connection = Database.connect(conn_string, **self.options) + try: + self.oracle_version = int(self.connection.version.split('.')[0]) + except ValueError: + pass cursor = FormatStylePlaceholderCursor(self.connection) # Default arraysize of 1 is highly sub-optimal. cursor.arraysize = 100 diff --git a/django/db/models/query.py b/django/db/models/query.py index a750ef5550..23d0bac6c8 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -816,6 +816,9 @@ def get_where_clause(lookup_type, table_prefix, field_name, value, db_type): return connection.ops.fulltext_search_sql(field_sql) elif lookup_type in ('regex', 'iregex'): if settings.DATABASE_ENGINE == 'oracle': + if connection.oracle_version and connection.oracle_version <= 9: + msg = "Regexes are not supported in Oracle before version 10g." + raise NotImplementedError(msg) if lookup_type == 'regex': match_option = 'c' else: |
