diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py index 06a111a75ba..d4651516fed 100644 --- a/django/db/backends/mysql/features.py +++ b/django/db/backends/mysql/features.py @@ -117,6 +117,10 @@ class DatabaseFeatures(BaseDatabaseFeatures): return self.connection.mysql_version >= (10, 3, 0) return self.connection.mysql_version >= (8, 0, 1) + @cached_property + def has_select_for_update_of(self): + return not self.connection.mysql_is_mariadb and self.connection.mysql_version >= (8, 0, 1) + @cached_property def supports_explain_analyze(self): return self.connection.mysql_is_mariadb or self.connection.mysql_version >= (8, 0, 18) diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 49eaccb0b3b..8c87eb68187 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -639,7 +639,7 @@ Option MariaDB MySQL =============== ========= ========== ``SKIP LOCKED`` X (≥8.0.1) ``NOWAIT`` X (≥10.3) X (≥8.0.1) -``OF`` +``OF`` X (≥8.0.1) ``NO KEY`` =============== ========= ========== diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 9f541d54143..bef69382632 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1729,9 +1729,9 @@ them:: Currently, the ``postgresql``, ``oracle``, and ``mysql`` database backends support ``select_for_update()``. However, MariaDB 10.3+ supports only -the ``nowait`` argument and MySQL 8.0.1+ supports the ``nowait`` and -``skip_locked`` arguments. MySQL and MariaDB don't support the ``of`` argument. -The ``no_key`` argument is supported only on PostgreSQL. +the ``nowait`` argument and MySQL 8.0.1+ supports the ``nowait``, +``skip_locked``, and ``of`` arguments. The ``no_key`` argument is supported +only on PostgreSQL. Passing ``nowait=True``, ``skip_locked=True``, ``no_key=True``, or ``of`` to ``select_for_update()`` using database backends that do not support these @@ -1769,6 +1769,8 @@ raised if ``select_for_update()`` is used in autocommit mode. The ``no_key`` argument was added. + The ``of`` argument was allowed on MySQL 8.0.1+. + ``raw()`` ~~~~~~~~~ diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt index 64b3b0257c1..653e14a3a1b 100644 --- a/docs/releases/3.2.txt +++ b/docs/releases/3.2.txt @@ -230,6 +230,9 @@ Models * :class:`FilteredRelation() ` now supports nested relations. +* The ``of`` argument of :meth:`.QuerySet.select_for_update()` is now allowed + on MySQL 8.0.1+. + Requests and Responses ~~~~~~~~~~~~~~~~~~~~~~