Used SQL from DB backend in GeomValue.

This avoids the deprecated GeomFromText on MySQL (refs #26134).

Thanks Claude Paroz for the review.
This commit is contained in:
Tim Graham 2016-06-13 11:27:52 -04:00
parent 4f336f6652
commit 9c3fbf5423
2 changed files with 5 additions and 9 deletions

View File

@ -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',

View File

@ -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):