mirror of https://github.com/django/django.git
Added MySQLOperations.geom_func_prefix to simplify.
This commit is contained in:
parent
6b5106b1ce
commit
7d51e406bd
|
@ -14,6 +14,10 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
|
||||||
Adapter = WKTAdapter
|
Adapter = WKTAdapter
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def geom_func_prefix(self):
|
||||||
|
return '' if self.is_mysql_5_5 else 'ST_'
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_mysql_5_5(self):
|
def is_mysql_5_5(self):
|
||||||
return self.connection.mysql_version < (5, 6, 1)
|
return self.connection.mysql_version < (5, 6, 1)
|
||||||
|
@ -28,21 +32,15 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def select(self):
|
def select(self):
|
||||||
if self.is_mysql_5_5:
|
return self.geom_func_prefix + 'AsText(%s)'
|
||||||
return 'AsText(%s)'
|
|
||||||
return 'ST_AsText(%s)'
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def from_wkb(self):
|
def from_wkb(self):
|
||||||
if self.is_mysql_5_5:
|
return self.geom_func_prefix + 'GeomFromWKB'
|
||||||
return 'GeomFromWKB'
|
|
||||||
return 'ST_GeomFromWKB'
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def from_text(self):
|
def from_text(self):
|
||||||
if self.is_mysql_5_5:
|
return self.geom_func_prefix + 'GeomFromText'
|
||||||
return 'GeomFromText'
|
|
||||||
return 'ST_GeomFromText'
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def gis_operators(self):
|
def gis_operators(self):
|
||||||
|
@ -64,19 +62,7 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def function_names(self):
|
def function_names(self):
|
||||||
return {
|
return {'Length': 'GLength'} if self.is_mysql_5_5 else {}
|
||||||
'Area': 'Area' if self.is_mysql_5_5 else 'ST_Area',
|
|
||||||
'Centroid': 'Centroid' if self.is_mysql_5_5 else 'ST_Centroid',
|
|
||||||
'Difference': 'ST_Difference',
|
|
||||||
'Distance': 'ST_Distance',
|
|
||||||
'Envelope': 'Envelope' if self.is_mysql_5_5 else 'ST_Envelope',
|
|
||||||
'Intersection': 'ST_Intersection',
|
|
||||||
'Length': 'GLength' if self.is_mysql_5_5 else 'ST_Length',
|
|
||||||
'NumGeometries': 'NumGeometries' if self.is_mysql_5_5 else 'ST_NumGeometries',
|
|
||||||
'NumPoints': 'NumPoints' if self.is_mysql_5_5 else 'ST_NumPoints',
|
|
||||||
'SymDifference': 'ST_SymDifference',
|
|
||||||
'Union': 'ST_Union',
|
|
||||||
}
|
|
||||||
|
|
||||||
disallowed_aggregates = (
|
disallowed_aggregates = (
|
||||||
aggregates.Collect, aggregates.Extent, aggregates.Extent3D,
|
aggregates.Collect, aggregates.Extent, aggregates.Extent3D,
|
||||||
|
|
Loading…
Reference in New Issue