From fc1961817115ae9737d64ca92942d02ce77d5fc2 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 12 Feb 2025 23:05:35 +0100 Subject: [PATCH] [5.2.x] Reverted "Fixed #35803 -- Added support for Collect, GeoHash, and IsValid on MariaDB 11.7+." This reverts commit c77573716a58af32ffcfc4fe87ff9e5c97909bd2. MariaDB reverted GIS functions. Backport of eb70aafdba18ac30e53056162c32ee6c21dea0b4 from main. --- .../gis/db/backends/mysql/operations.py | 8 ++---- docs/ref/contrib/gis/db-api.txt | 25 +++++++++-------- docs/ref/contrib/gis/functions.txt | 12 ++------ docs/ref/contrib/gis/geoquerysets.txt | 28 +++++++------------ docs/releases/5.2.txt | 6 +--- 5 files changed, 28 insertions(+), 51 deletions(-) diff --git a/django/contrib/gis/db/backends/mysql/operations.py b/django/contrib/gis/db/backends/mysql/operations.py index 5c02d5e5a7..674931b938 100644 --- a/django/contrib/gis/db/backends/mysql/operations.py +++ b/django/contrib/gis/db/backends/mysql/operations.py @@ -73,10 +73,7 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations): models.Union, ] is_mariadb = self.connection.mysql_is_mariadb - if is_mariadb: - if self.connection.mysql_version < (11, 7): - disallowed_aggregates.insert(0, models.Collect) - elif self.connection.mysql_version < (8, 0, 24): + if is_mariadb or self.connection.mysql_version < (8, 0, 24): disallowed_aggregates.insert(0, models.Collect) return tuple(disallowed_aggregates) @@ -110,8 +107,7 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations): } if self.connection.mysql_is_mariadb: unsupported.remove("PointOnSurface") - if self.connection.mysql_version < (11, 7): - unsupported.update({"GeoHash", "IsValid"}) + unsupported.update({"GeoHash", "IsValid"}) return unsupported def geo_db_type(self, f): diff --git a/docs/ref/contrib/gis/db-api.txt b/docs/ref/contrib/gis/db-api.txt index c832f216ad..02b8fafb34 100644 --- a/docs/ref/contrib/gis/db-api.txt +++ b/docs/ref/contrib/gis/db-api.txt @@ -360,7 +360,7 @@ Lookup Type PostGIS Oracle MariaDB MySQL [#]_ S :lookup:`exact ` X X X X X B :lookup:`intersects` X X X X X B :lookup:`isempty` X -:lookup:`isvalid` X X X (≥ 11.7) X X +:lookup:`isvalid` X X X X :lookup:`overlaps` X X X X X B :lookup:`relate` X X X X C :lookup:`same_as` X X X X X B @@ -406,11 +406,11 @@ Function PostGIS Oracle MariaDB MySQL :class:`ForcePolygonCW` X X :class:`FromWKB` X X X X X :class:`FromWKT` X X X X X -:class:`GeoHash` X X (≥ 11.7) X X (LWGEOM/RTTOPO) +:class:`GeoHash` X X X (LWGEOM/RTTOPO) :class:`GeometryDistance` X :class:`Intersection` X X X X X :class:`IsEmpty` X -:class:`IsValid` X X X (≥ 11.7) X X +:class:`IsValid` X X X X :class:`Length` X X X X X :class:`LineLocatePoint` X X :class:`MakeValid` X X (LWGEOM/RTTOPO) @@ -432,19 +432,20 @@ Aggregate Functions ------------------- The following table provides a summary of what GIS-specific aggregate functions -are available on each spatial backend. +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 MariaDB MySQL SpatiaLite -======================= ======= ====== ========== ============ ========== -:class:`Collect` X X (≥ 11.7) X (≥ 8.0.24) X -:class:`Extent` X 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 -======================= ======= ====== ========== ============ ========== +:class:`MakeLine` X X +:class:`Union` X X X +======================= ======= ====== ============ ========== .. rubric:: Footnotes .. [#fnwkt] *See* Open Geospatial Consortium, Inc., `OpenGIS Simple Feature Specification For SQL `_, Document 99-049 (May 5, 1999), at Ch. 3.2.5, p. 3-11 (SQL Textual Representation of Geometry). diff --git a/docs/ref/contrib/gis/functions.txt b/docs/ref/contrib/gis/functions.txt index ff62c17580..ff05d0ec96 100644 --- a/docs/ref/contrib/gis/functions.txt +++ b/docs/ref/contrib/gis/functions.txt @@ -393,7 +393,7 @@ Creates geometry from `Well-known text (WKT)`_ representation. The optional .. class:: GeoHash(expression, precision=None, **extra) -*Availability*: MariaDB, `MySQL +*Availability*: `MySQL `__, `PostGIS `__, SpatiaLite (LWGEOM/RTTOPO) @@ -406,10 +406,6 @@ result. __ https://en.wikipedia.org/wiki/Geohash -.. versionchanged:: 5.2 - - MariaDB 11.7+ support was added. - ``GeometryDistance`` ==================== @@ -448,17 +444,13 @@ geometry. Returns ``True`` if its value is empty and ``False`` otherwise. .. class:: IsValid(expr) -*Availability*: MariaDB, `MySQL +*Availability*: `MySQL `__, `PostGIS `__, Oracle, SpatiaLite Accepts a geographic field or expression and tests if the value is well formed. Returns ``True`` if its value is a valid geometry and ``False`` otherwise. -.. versionchanged:: 5.2 - - MariaDB 11.7+ support was added. - ``Length`` ========== diff --git a/docs/ref/contrib/gis/geoquerysets.txt b/docs/ref/contrib/gis/geoquerysets.txt index 19411b7304..6384dad2c9 100644 --- a/docs/ref/contrib/gis/geoquerysets.txt +++ b/docs/ref/contrib/gis/geoquerysets.txt @@ -375,8 +375,8 @@ Example:: ``isvalid`` ----------- -*Availability*: MariaDB, MySQL, -`PostGIS `__, Oracle, SpatiaLite +*Availability*: MySQL, `PostGIS `__, +Oracle, SpatiaLite Tests if the geometry is valid. @@ -384,16 +384,12 @@ Example:: Zipcode.objects.filter(poly__isvalid=True) -=================================== ================================================================ -Backend SQL Equivalent -=================================== ================================================================ -MariaDB, MySQL, PostGIS, SpatiaLite ``ST_IsValid(poly)`` -Oracle ``SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(poly, 0.05) = 'TRUE'`` -=================================== ================================================================ - -.. versionchanged:: 5.2 - - MariaDB 11.7+ support was added. +========================== ================================================================ +Backend SQL Equivalent +========================== ================================================================ +MySQL, PostGIS, SpatiaLite ``ST_IsValid(poly)`` +Oracle ``SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(poly, 0.05) = 'TRUE'`` +========================== ================================================================ .. fieldlookup:: overlaps @@ -885,8 +881,8 @@ Example: .. class:: Collect(geo_field, filter=None) -*Availability*: `PostGIS `__, -MariaDB, MySQL, SpatiaLite +*Availability*: `PostGIS `__, MySQL, +SpatiaLite Returns a ``GEOMETRYCOLLECTION`` or a ``MULTI`` geometry object from the geometry column. This is analogous to a simplified version of the :class:`Union` @@ -898,10 +894,6 @@ caring about dissolving boundaries. MySQL 8.0.24+ support was added. -.. versionchanged:: 5.2 - - MariaDB 11.7+ support was added. - ``Extent`` ~~~~~~~~~~ diff --git a/docs/releases/5.2.txt b/docs/releases/5.2.txt index 15dad66b54..890b2ad288 100644 --- a/docs/releases/5.2.txt +++ b/docs/releases/5.2.txt @@ -199,11 +199,7 @@ Minor features * :lookup:`coveredby` and :lookup:`covers` lookup are now supported on MySQL. -* :lookup:`coveredby` and :lookup:`isvalid` lookups, - :class:`~django.contrib.gis.db.models.Collect` aggregation, and - :class:`~django.contrib.gis.db.models.functions.GeoHash` and - :class:`~django.contrib.gis.db.models.functions.IsValid` database functions - are now supported on MariaDB 11.7+. +* :lookup:`coveredby` lookup is now supported on MariaDB 11.7+. :mod:`django.contrib.syndication` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~