mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
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:
parent
4f336f6652
commit
9c3fbf5423
@ -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',
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user