diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 2a166f23a1..a6a0f464c9 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -78,6 +78,8 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations): union = 'SDO_GEOM.SDO_UNION' unionagg = 'SDO_AGGR_UNION' + from_text = 'SDO_GEOMETRY' + function_names = { 'Area': 'SDO_GEOM.SDO_AREA', 'Centroid': 'SDO_GEOM.SDO_CENTROID', diff --git a/django/contrib/gis/db/models/functions.py b/django/contrib/gis/db/models/functions.py index 7355bbcbfc..b98a2e134b 100644 --- a/django/contrib/gis/db/models/functions.py +++ b/django/contrib/gis/db/models/functions.py @@ -72,21 +72,15 @@ class GeomValue(Value): return self.value.srid def as_sql(self, compiler, connection): + return '%s(%%s, %s)' % (connection.ops.from_text, self.srid), [connection.ops.Adapter(self.value)] + + def as_postgresql(self, compiler, connection): if self.geography: self.value = connection.ops.Adapter(self.value, geography=self.geography) else: self.value = connection.ops.Adapter(self.value) return super(GeomValue, self).as_sql(compiler, connection) - def as_mysql(self, compiler, connection): - return 'GeomFromText(%%s, %s)' % self.srid, [connection.ops.Adapter(self.value)] - - def as_sqlite(self, compiler, connection): - return 'GeomFromText(%%s, %s)' % self.srid, [connection.ops.Adapter(self.value)] - - def as_oracle(self, compiler, connection): - return 'SDO_GEOMETRY(%%s, %s)' % self.srid, [connection.ops.Adapter(self.value)] - class GeoFuncWithGeoParam(GeoFunc): def __init__(self, expression, geom, *expressions, **extra):