mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
[1.10.x] Used SQL from DB backend in GeomValue.
This avoids the deprecated GeomFromText on MySQL (refs #26134). Thanks Claude Paroz for the review. Backport of 9c3fbf5423367cdcf1a30a411793919d86f5288c from master
This commit is contained in:
parent
13d60298ea
commit
f94f4db0a3
@ -78,6 +78,8 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations):
|
|||||||
union = 'SDO_GEOM.SDO_UNION'
|
union = 'SDO_GEOM.SDO_UNION'
|
||||||
unionagg = 'SDO_AGGR_UNION'
|
unionagg = 'SDO_AGGR_UNION'
|
||||||
|
|
||||||
|
from_text = 'SDO_GEOMETRY'
|
||||||
|
|
||||||
function_names = {
|
function_names = {
|
||||||
'Area': 'SDO_GEOM.SDO_AREA',
|
'Area': 'SDO_GEOM.SDO_AREA',
|
||||||
'Centroid': 'SDO_GEOM.SDO_CENTROID',
|
'Centroid': 'SDO_GEOM.SDO_CENTROID',
|
||||||
|
@ -72,21 +72,15 @@ class GeomValue(Value):
|
|||||||
return self.value.srid
|
return self.value.srid
|
||||||
|
|
||||||
def as_sql(self, compiler, connection):
|
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:
|
if self.geography:
|
||||||
self.value = connection.ops.Adapter(self.value, geography=self.geography)
|
self.value = connection.ops.Adapter(self.value, geography=self.geography)
|
||||||
else:
|
else:
|
||||||
self.value = connection.ops.Adapter(self.value)
|
self.value = connection.ops.Adapter(self.value)
|
||||||
return super(GeomValue, self).as_sql(compiler, connection)
|
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):
|
class GeoFuncWithGeoParam(GeoFunc):
|
||||||
def __init__(self, expression, geom, *expressions, **extra):
|
def __init__(self, expression, geom, *expressions, **extra):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user