mirror of
https://github.com/django/django.git
synced 2025-04-25 17:54:37 +00:00
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):
|
def from_text(self):
|
||||||
return self.geom_func_prefix + "GeomFromText"
|
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
|
@cached_property
|
||||||
def gis_operators(self):
|
def gis_operators(self):
|
||||||
operators = {
|
operators = {
|
||||||
@ -54,13 +59,18 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
|||||||
operators["relate"] = SpatialOperator(func="ST_Relate")
|
operators["relate"] = SpatialOperator(func="ST_Relate")
|
||||||
return operators
|
return operators
|
||||||
|
|
||||||
disallowed_aggregates = (
|
@cached_property
|
||||||
models.Collect,
|
def disallowed_aggregates(self):
|
||||||
models.Extent,
|
disallowed_aggregates = [
|
||||||
models.Extent3D,
|
models.Extent,
|
||||||
models.MakeLine,
|
models.Extent3D,
|
||||||
models.Union,
|
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 = {
|
function_names = {
|
||||||
"FromWKB": "ST_GeomFromWKB",
|
"FromWKB": "ST_GeomFromWKB",
|
||||||
@ -128,3 +138,6 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
|||||||
return geom
|
return geom
|
||||||
|
|
||||||
return converter
|
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
|
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.
|
support any of these aggregates, and is thus excluded from the table.
|
||||||
|
|
||||||
.. currentmodule:: django.contrib.gis.db.models
|
.. currentmodule:: django.contrib.gis.db.models
|
||||||
|
|
||||||
======================= ======= ====== ==========
|
======================= ======= ====== ============ ==========
|
||||||
Aggregate PostGIS Oracle SpatiaLite
|
Aggregate PostGIS Oracle MySQL SpatiaLite
|
||||||
======================= ======= ====== ==========
|
======================= ======= ====== ============ ==========
|
||||||
:class:`Collect` X X
|
:class:`Collect` X X (≥ 8.0.24) X
|
||||||
:class:`Extent` X X X
|
:class:`Extent` X X X
|
||||||
:class:`Extent3D` X
|
:class:`Extent3D` X
|
||||||
:class:`MakeLine` X X
|
:class:`MakeLine` X X
|
||||||
:class:`Union` X X X
|
:class:`Union` X X X
|
||||||
======================= ======= ====== ==========
|
======================= ======= ====== ============ ==========
|
||||||
|
|
||||||
.. rubric:: Footnotes
|
.. 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).
|
.. [#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)
|
.. 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
|
SpatiaLite
|
||||||
|
|
||||||
Returns a ``GEOMETRYCOLLECTION`` or a ``MULTI`` geometry object from the geometry
|
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.
|
Support for using the ``filter`` argument was added.
|
||||||
|
|
||||||
|
.. versionchanged:: 5.1
|
||||||
|
|
||||||
|
MySQL 8.0.24+ support was added.
|
||||||
|
|
||||||
``Extent``
|
``Extent``
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -56,6 +56,9 @@ Minor features
|
|||||||
* :class:`~django.contrib.gis.db.models.functions.BoundingCircle` is now
|
* :class:`~django.contrib.gis.db.models.functions.BoundingCircle` is now
|
||||||
supported on SpatiaLite 5.1+.
|
supported on SpatiaLite 5.1+.
|
||||||
|
|
||||||
|
* :class:`~django.contrib.gis.db.models.Collect` is now supported on MySQL
|
||||||
|
8.0.24+.
|
||||||
|
|
||||||
:mod:`django.contrib.messages`
|
:mod:`django.contrib.messages`
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user