From 185ab9ffefcf81378d7da02dddca0a59487b9613 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 18 Sep 2014 15:44:37 -0400 Subject: [PATCH] Fixed Oracle GIS failures introduced by e9103402c0; refs #18757. Thanks Marc Tamlyn for the patch. --- django/contrib/gis/db/backends/oracle/operations.py | 11 +++++++++++ django/contrib/gis/db/models/fields.py | 2 +- django/contrib/gis/db/models/sql/compiler.py | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 3af78929f8..4beb5a1589 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -142,6 +142,17 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations): truncate_params = {'relate': None} + def get_db_converters(self, internal_type): + converters = super(OracleOperations, self).get_db_converters(internal_type) + geometry_fields = ( + 'PointField', 'GeometryField', 'LineStringField', + 'PolygonField', 'MultiPointField', 'MultiLineStringField', + 'MultiPolygonField', 'GeometryCollectionField', 'GeomField', + ) + if internal_type in geometry_fields: + converters.append(self.convert_textfield_value) + return converters + def convert_extent(self, clob): if clob: # Generally, Oracle returns a polygon for the extent -- however, diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index 2e0e13abf9..c79548ed8a 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -198,7 +198,7 @@ class GeometryField(Field): return geom def from_db_value(self, value, connection): - if value is not None: + if value: value = Geometry(value) return value diff --git a/django/contrib/gis/db/models/sql/compiler.py b/django/contrib/gis/db/models/sql/compiler.py index e721514085..05491ef930 100644 --- a/django/contrib/gis/db/models/sql/compiler.py +++ b/django/contrib/gis/db/models/sql/compiler.py @@ -152,7 +152,8 @@ class GeoSQLCompiler(compiler.SQLCompiler): for i, alias in enumerate(self.query.extra_select): field = self.query.extra_select_fields.get(alias) if field: - converters[i] = ([], [field.from_db_value], field) + backend_converters = self.connection.ops.get_db_converters(field.get_internal_type()) + converters[i] = (backend_converters, [field.from_db_value], field) return converters #### Routines unique to GeoQuery ####