mirror of https://github.com/django/django.git
Fixed #35088 -- Added support for Collect on MySQL 8.0.24+.
This commit is contained in:
parent
5c043286e2
commit
53fc6ac649
|
@ -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,
|
||||
@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())
|
||||
|
|
|
@ -431,20 +431,20 @@ Aggregate Functions
|
|||
-------------------
|
||||
|
||||
The following table provides a summary of what GIS-specific aggregate functions
|
||||
are available on each spatial backend. Please note that MySQL does not
|
||||
are available on each spatial backend. Please note that MariaDB does not
|
||||
support any of these aggregates, and is thus excluded from the table.
|
||||
|
||||
.. currentmodule:: django.contrib.gis.db.models
|
||||
|
||||
======================= ======= ====== ==========
|
||||
Aggregate PostGIS Oracle SpatiaLite
|
||||
======================= ======= ====== ==========
|
||||
:class:`Collect` X X
|
||||
======================= ======= ====== ============ ==========
|
||||
Aggregate PostGIS Oracle MySQL SpatiaLite
|
||||
======================= ======= ====== ============ ==========
|
||||
:class:`Collect` X X (≥ 8.0.24) X
|
||||
:class:`Extent` X X X
|
||||
:class:`Extent3D` X
|
||||
:class:`MakeLine` X X
|
||||
:class:`Union` X X X
|
||||
======================= ======= ====== ==========
|
||||
======================= ======= ====== ============ ==========
|
||||
|
||||
.. rubric:: Footnotes
|
||||
.. [#fnwkt] *See* Open Geospatial Consortium, Inc., `OpenGIS Simple Feature Specification For SQL <https://portal.ogc.org/files/?artifact_id=829>`_, Document 99-049 (May 5, 1999), at Ch. 3.2.5, p. 3-11 (SQL Textual Representation of Geometry).
|
||||
|
|
|
@ -870,7 +870,7 @@ Example:
|
|||
|
||||
.. class:: Collect(geo_field, filter=None)
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Collect.html>`__,
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Collect.html>`__, MySQL,
|
||||
SpatiaLite
|
||||
|
||||
Returns a ``GEOMETRYCOLLECTION`` or a ``MULTI`` geometry object from the geometry
|
||||
|
@ -883,6 +883,10 @@ caring about dissolving boundaries.
|
|||
|
||||
Support for using the ``filter`` argument was added.
|
||||
|
||||
.. versionchanged:: 5.1
|
||||
|
||||
MySQL 8.0.24+ support was added.
|
||||
|
||||
``Extent``
|
||||
~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -56,6 +56,9 @@ Minor features
|
|||
* :class:`~django.contrib.gis.db.models.functions.BoundingCircle` is now
|
||||
supported on SpatiaLite 5.1+.
|
||||
|
||||
* :class:`~django.contrib.gis.db.models.Collect` is now supported on MySQL
|
||||
8.0.24+.
|
||||
|
||||
:mod:`django.contrib.messages`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
Loading…
Reference in New Issue