diff --git a/django/contrib/gis/db/backends/mysql/operations.py b/django/contrib/gis/db/backends/mysql/operations.py index e9aec1e96c..5c02d5e5a7 100644 --- a/django/contrib/gis/db/backends/mysql/operations.py +++ b/django/contrib/gis/db/backends/mysql/operations.py @@ -60,6 +60,8 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations): 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 diff --git a/docs/ref/contrib/gis/db-api.txt b/docs/ref/contrib/gis/db-api.txt index b587f1d9be..e33d9a514f 100644 --- a/docs/ref/contrib/gis/db-api.txt +++ b/docs/ref/contrib/gis/db-api.txt @@ -348,7 +348,7 @@ Lookup Type PostGIS Oracle MariaDB MySQL [#]_ S :lookup:`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 diff --git a/docs/ref/contrib/gis/geoquerysets.txt b/docs/ref/contrib/gis/geoquerysets.txt index 607e743a2d..19411b7304 100644 --- a/docs/ref/contrib/gis/geoquerysets.txt +++ b/docs/ref/contrib/gis/geoquerysets.txt @@ -212,7 +212,7 @@ SpatiaLite ``CoveredBy(poly, geom)`` ---------- *Availability*: `PostGIS `__, -Oracle, PGRaster (Bilateral), SpatiaLite +Oracle, MySQL, PGRaster (Bilateral), SpatiaLite Tests if no point in the lookup geometry is outside the geometry field. [#fncovers]_ @@ -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`` diff --git a/docs/releases/5.2.txt b/docs/releases/5.2.txt index 72fd0e219b..e103de847b 100644 --- a/docs/releases/5.2.txt +++ b/docs/releases/5.2.txt @@ -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