1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #35088 -- Added support for Collect on MySQL 8.0.24+.

This commit is contained in:
Nick Pope
2024-01-06 14:07:49 +00:00
committed by GitHub
parent 5c043286e2
commit 53fc6ac649
4 changed files with 37 additions and 17 deletions

View File

@@ -31,6 +31,11 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
def from_text(self):
return self.geom_func_prefix + "GeomFromText"
@cached_property
def collect(self):
if self.connection.features.supports_collect_aggr:
return self.geom_func_prefix + "Collect"
@cached_property
def gis_operators(self):
operators = {
@@ -54,13 +59,18 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
operators["relate"] = SpatialOperator(func="ST_Relate")
return operators
disallowed_aggregates = (
models.Collect,
models.Extent,
models.Extent3D,
models.MakeLine,
models.Union,
)
@cached_property
def disallowed_aggregates(self):
disallowed_aggregates = [
models.Extent,
models.Extent3D,
models.MakeLine,
models.Union,
]
is_mariadb = self.connection.mysql_is_mariadb
if is_mariadb or self.connection.mysql_version < (8, 0, 24):
disallowed_aggregates.insert(0, models.Collect)
return tuple(disallowed_aggregates)
function_names = {
"FromWKB": "ST_GeomFromWKB",
@@ -128,3 +138,6 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
return geom
return converter
def spatial_aggregate_name(self, agg_name):
return getattr(self, agg_name.lower())