[2.2.x] Fixed #30928 -- Clarified MySQL/MariaDB support of QuerySet.select_for_update() options.

Thanks Par Andersson for reporting the issue.

Backport of d94d7b113c from master
This commit is contained in:
kola-er 2019-11-04 22:44:10 +01:00 committed by Mariusz Felisiak
parent 406fb336b7
commit 22466f91dc
2 changed files with 13 additions and 5 deletions

View File

@ -612,10 +612,17 @@ both MySQL and Django will attempt to convert the values from UTC to local time.
Row locking with ``QuerySet.select_for_update()`` Row locking with ``QuerySet.select_for_update()``
------------------------------------------------- -------------------------------------------------
MySQL does not support the ``NOWAIT``, ``SKIP LOCKED``, and ``OF`` options to MySQL does not support some options to the ``SELECT ... FOR UPDATE`` statement.
the ``SELECT ... FOR UPDATE`` statement. If ``select_for_update()`` is used If ``select_for_update()`` is used with an unsupported option, then
with ``nowait=True``, ``skip_locked=True``, or ``of`` then a a :exc:`~django.db.NotSupportedError` is raised.
:exc:`~django.db.NotSupportedError` is raised.
=============== ==========
Option MySQL
=============== ==========
``SKIP LOCKED`` X (≥8.0.1)
``NOWAIT`` X (≥8.0.1)
``OF``
=============== ==========
When using ``select_for_update()`` on MySQL, make sure you filter a queryset When using ``select_for_update()`` on MySQL, make sure you filter a queryset
against at least set of fields contained in unique constraints or only against against at least set of fields contained in unique constraints or only against

View File

@ -1711,7 +1711,8 @@ them::
Currently, the ``postgresql``, ``oracle``, and ``mysql`` database Currently, the ``postgresql``, ``oracle``, and ``mysql`` database
backends support ``select_for_update()``. However, MySQL doesn't support the backends support ``select_for_update()``. However, MySQL doesn't support the
``nowait``, ``skip_locked``, and ``of`` arguments. ``of`` argument and the ``nowait`` and ``skip_locked`` arguments are supported
only on MySQL 8.0.1+.
Passing ``nowait=True``, ``skip_locked=True``, or ``of`` to Passing ``nowait=True``, ``skip_locked=True``, or ``of`` to
``select_for_update()`` using database backends that do not support these ``select_for_update()`` using database backends that do not support these