1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #19198 -- merged 4 different Oracle fixes

This commit is contained in:
Anssi Kääriäinen
2012-10-27 19:05:41 +03:00
6 changed files with 42 additions and 9 deletions

View File

@@ -26,7 +26,7 @@ mysql = _default_db == 'mysql'
spatialite = _default_db == 'spatialite'
HAS_SPATIALREFSYS = True
if oracle:
if oracle and 'gis' in settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE']:
from django.contrib.gis.db.backends.oracle.models import SpatialRefSys
elif postgis:
from django.contrib.gis.db.backends.postgis.models import SpatialRefSys

View File

@@ -256,6 +256,10 @@ WHEN (new.%(col_name)s IS NULL)
if not name.startswith('"') and not name.endswith('"'):
name = '"%s"' % util.truncate_name(name.upper(),
self.max_name_length())
# Oracle puts the query text into a (query % args) construct, so % signs
# in names need to be escaped. The '%%' will be collapsed back to '%' at
# that stage so we aren't really making the name longer here.
name = name.replace('%','%%')
return name.upper()
def random_function_sql(self):

View File

@@ -1418,8 +1418,15 @@ def get_cached_row(row, index_start, using, klass_info, offset=0):
fields = row[index_start : index_start + field_count]
# If all the select_related columns are None, then the related
# object must be non-existent - set the relation to None.
# Otherwise, construct the related object.
if fields == (None,) * field_count:
# Otherwise, construct the related object. Also, some backends treat ''
# and None equivalently for char fields, so we have to be prepared for
# '' values.
if connections[using].features.interprets_empty_strings_as_nulls:
vals = tuple([None if f == '' else f for f in fields])
else:
vals = fields
if vals == (None,) * field_count:
obj = None
else:
if field_names: