diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 4beb5a1589..aa06e98433 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -148,6 +148,7 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations): 'PointField', 'GeometryField', 'LineStringField', 'PolygonField', 'MultiPointField', 'MultiLineStringField', 'MultiPolygonField', 'GeometryCollectionField', 'GeomField', + 'GMLField', ) if internal_type in geometry_fields: converters.append(self.convert_textfield_value) diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py index 198a6288c0..cbc1536b8a 100644 --- a/django/contrib/gis/db/models/query.py +++ b/django/contrib/gis/db/models/query.py @@ -3,7 +3,7 @@ from django.db.models.query import QuerySet from django.contrib.gis.db.models import aggregates from django.contrib.gis.db.models.fields import get_srid_info, PointField, LineStringField -from django.contrib.gis.db.models.sql import AreaField, DistanceField, GeomField, GeoQuery +from django.contrib.gis.db.models.sql import AreaField, DistanceField, GeomField, GeoQuery, GMLField from django.contrib.gis.geometry.backend import Geometry from django.contrib.gis.measure import Area, Distance @@ -175,6 +175,8 @@ class GeoQuerySet(QuerySet): if backend.postgis: s['procedure_fmt'] = '%(version)s,%(geo_col)s,%(precision)s' s['procedure_args'] = {'precision': precision, 'version': version} + if backend.oracle: + s['select_field'] = GMLField() return self._spatial_attribute('gml', s, **kwargs) diff --git a/django/contrib/gis/db/models/sql/__init__.py b/django/contrib/gis/db/models/sql/__init__.py index cde4c2d5e6..fc965c5c67 100644 --- a/django/contrib/gis/db/models/sql/__init__.py +++ b/django/contrib/gis/db/models/sql/__init__.py @@ -1,6 +1,6 @@ -from django.contrib.gis.db.models.sql.conversion import AreaField, DistanceField, GeomField +from django.contrib.gis.db.models.sql.conversion import AreaField, DistanceField, GeomField, GMLField from django.contrib.gis.db.models.sql.query import GeoQuery __all__ = [ - 'AreaField', 'DistanceField', 'GeomField', 'GeoQuery', + 'AreaField', 'DistanceField', 'GeomField', 'GMLField', 'GeoQuery', ] diff --git a/django/contrib/gis/db/models/sql/conversion.py b/django/contrib/gis/db/models/sql/conversion.py index 2908828b80..98112b3285 100644 --- a/django/contrib/gis/db/models/sql/conversion.py +++ b/django/contrib/gis/db/models/sql/conversion.py @@ -51,3 +51,15 @@ class GeomField(BaseField): def get_internal_type(self): return 'GeometryField' + + +class GMLField(BaseField): + """ + Wrapper for GML to be used by Oracle to ensure Database.LOB conversion. + """ + + def get_internal_type(self): + return 'GMLField' + + def from_db_value(self, value, connection): + return value