Skip to content

Commit

Permalink
Refs #35803 -- Added support for __covers GIS lookup on MySQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixxm authored and sarahboyce committed Oct 25, 2024
1 parent c775737 commit 5cf88dc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions django/contrib/gis/db/backends/mysql/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def gis_operators(self):
operators["relate"] = SpatialOperator(func="ST_Relate")
if self.connection.mysql_version < (11, 7):
del operators["coveredby"]
else:
operators["covers"] = SpatialOperator(func="MBRCovers")
return operators

@cached_property
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/contrib/gis/db-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ Lookup Type PostGIS Oracle MariaDB MySQL [#]_ S
:lookup:`contains <gis-contains>` X X X X X B
:lookup:`contains_properly` X B
:lookup:`coveredby` X X X (≥ 11.7) X X B
:lookup:`covers` X X X B
:lookup:`covers` X X X X B
:lookup:`crosses` X X X X C
:lookup:`disjoint` X X X X X B
:lookup:`distance_gt` X X X X X N
Expand Down
7 changes: 6 additions & 1 deletion docs/ref/contrib/gis/geoquerysets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ SpatiaLite ``CoveredBy(poly, geom)``
----------

*Availability*: `PostGIS <https://postgis.net/docs/ST_Covers.html>`__,
Oracle, PGRaster (Bilateral), SpatiaLite
Oracle, MySQL, PGRaster (Bilateral), SpatiaLite

Tests if no point in the lookup geometry is outside the geometry field.
[#fncovers]_
Expand All @@ -226,9 +226,14 @@ Backend SQL Equivalent
========== ==========================
PostGIS ``ST_Covers(poly, geom)``
Oracle ``SDO_COVERS(poly, geom)``
MySQL ``MBRCovers(poly, geom)``
SpatiaLite ``Covers(poly, geom)``
========== ==========================

.. versionchanged:: 5.2

MySQL support was added.

.. fieldlookup:: crosses

``crosses``
Expand Down
2 changes: 1 addition & 1 deletion docs/releases/5.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Minor features
:meth:`.OGRGeometry.get_linear_geometry` and
:meth:`.OGRGeometry.get_curve_geometry` methods.

* :lookup:`coveredby` lookup is now supported on MySQL.
* :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
Expand Down

0 comments on commit 5cf88dc

Please sign in to comment.