Refs #29548 -- Fixed GIS tests on MariaDB
This commit is contained in:
parent
a07a49ee32
commit
c28bf990d7
|
@ -29,9 +29,10 @@ class MySQLIntrospection(DatabaseIntrospection):
|
||||||
return field_type, field_params
|
return field_type, field_params
|
||||||
|
|
||||||
def supports_spatial_index(self, cursor, table_name):
|
def supports_spatial_index(self, cursor, table_name):
|
||||||
# Supported with MyISAM, or InnoDB on MySQL 5.7.5+
|
# Supported with MyISAM/Aria, or InnoDB on MySQL 5.7.5+/MariaDB 10.2.2+
|
||||||
storage_engine = self.get_storage_engine(cursor, table_name)
|
storage_engine = self.get_storage_engine(cursor, table_name)
|
||||||
return (
|
if storage_engine == 'InnoDB':
|
||||||
(storage_engine == 'InnoDB' and self.connection.mysql_version >= (5, 7, 5)) or
|
return self.connection.mysql_version >= (
|
||||||
storage_engine == 'MyISAM'
|
(10, 2, 2) if self.connection.mysql_is_mariadb else (5, 7, 5)
|
||||||
)
|
)
|
||||||
|
return storage_engine in ('MyISAM', 'Aria')
|
||||||
|
|
|
@ -19,10 +19,6 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
|
||||||
Adapter = WKTAdapter
|
Adapter = WKTAdapter
|
||||||
|
|
||||||
@cached_property
|
|
||||||
def is_mysql_5_6(self):
|
|
||||||
return self.connection.mysql_version < (5, 7, 6)
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def select(self):
|
def select(self):
|
||||||
return self.geom_func_prefix + 'AsBinary(%s)'
|
return self.geom_func_prefix + 'AsBinary(%s)'
|
||||||
|
@ -33,7 +29,9 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def gis_operators(self):
|
def gis_operators(self):
|
||||||
MBREquals = 'MBREqual' if self.is_mysql_5_6 else 'MBREquals'
|
MBREquals = 'MBREqual' if (
|
||||||
|
self.connection.mysql_is_mariadb or self.connection.mysql_version < (5, 7, 6)
|
||||||
|
) else 'MBREquals'
|
||||||
return {
|
return {
|
||||||
'bbcontains': SpatialOperator(func='MBRContains'), # For consistency w/PostGIS API
|
'bbcontains': SpatialOperator(func='MBRContains'), # For consistency w/PostGIS API
|
||||||
'bboverlaps': SpatialOperator(func='MBROverlaps'), # ...
|
'bboverlaps': SpatialOperator(func='MBROverlaps'), # ...
|
||||||
|
@ -62,7 +60,11 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
'MemSize', 'Perimeter', 'PointOnSurface', 'Reverse', 'Scale',
|
'MemSize', 'Perimeter', 'PointOnSurface', 'Reverse', 'Scale',
|
||||||
'SnapToGrid', 'Transform', 'Translate',
|
'SnapToGrid', 'Transform', 'Translate',
|
||||||
}
|
}
|
||||||
if self.connection.mysql_version < (5, 7, 5):
|
if self.connection.mysql_is_mariadb:
|
||||||
|
unsupported.update({'GeoHash', 'IsValid'})
|
||||||
|
if self.connection.mysql_version < (10, 2, 4):
|
||||||
|
unsupported.add('AsGeoJSON')
|
||||||
|
elif self.connection.mysql_version < (5, 7, 5):
|
||||||
unsupported.update({'AsGeoJSON', 'GeoHash', 'IsValid'})
|
unsupported.update({'AsGeoJSON', 'GeoHash', 'IsValid'})
|
||||||
return unsupported
|
return unsupported
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,10 @@ class OGRInspectTest(TestCase):
|
||||||
else:
|
else:
|
||||||
self.assertIn(' f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', model_def)
|
self.assertIn(' f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', model_def)
|
||||||
self.assertIn(' f_int = models.IntegerField()', model_def)
|
self.assertIn(' f_int = models.IntegerField()', model_def)
|
||||||
self.assertIn(' f_datetime = models.DateTimeField()', model_def)
|
if connection.vendor != 'mysql' or not connection.mysql_is_mariadb:
|
||||||
self.assertIn(' f_time = models.TimeField()', model_def)
|
# Probably a bug between GDAL and MariaDB on time fields.
|
||||||
|
self.assertIn(' f_datetime = models.DateTimeField()', model_def)
|
||||||
|
self.assertIn(' f_time = models.TimeField()', model_def)
|
||||||
if connection.vendor == 'sqlite':
|
if connection.vendor == 'sqlite':
|
||||||
self.assertIn(' f_float = models.CharField(max_length=0)', model_def)
|
self.assertIn(' f_float = models.CharField(max_length=0)', model_def)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue