diff options
Diffstat (limited to 'docs/ref/models')
| -rw-r--r-- | docs/ref/models/querysets.txt | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 3f4fce1a26..8d2e3ebb3b 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1528,7 +1528,7 @@ For example:: ``select_for_update()`` ~~~~~~~~~~~~~~~~~~~~~~~ -.. method:: select_for_update(nowait=False) +.. method:: select_for_update(nowait=False, skip_locked=False) Returns a queryset that will lock rows until the end of the transaction, generating a ``SELECT ... FOR UPDATE`` SQL statement on supported databases. @@ -1546,16 +1546,19 @@ selected rows, the query will block until the lock is released. If this is not the behavior you want, call ``select_for_update(nowait=True)``. This will make the call non-blocking. If a conflicting lock is already acquired by another transaction, :exc:`~django.db.DatabaseError` will be raised when the -queryset is evaluated. +queryset is evaluated. You can also ignore locked rows by using +``select_for_update(skip_locked=True)`` instead. The ``nowait`` and +``skip_locked`` are mutually exclusive and attempts to call +``select_for_update()`` with both options enabled will result in a +:exc:`ValueError`. Currently, the ``postgresql``, ``oracle``, and ``mysql`` database -backends support ``select_for_update()``. However, MySQL has no support for the -``nowait`` argument. Obviously, users of external third-party backends should -check with their backend's documentation for specifics in those cases. +backends support ``select_for_update()``. However, MySQL doesn't support the +``nowait`` and ``skip_locked`` arguments. -Passing ``nowait=True`` to ``select_for_update()`` using database backends that -do not support ``nowait``, such as MySQL, will cause a -:exc:`~django.db.DatabaseError` to be raised. This is in order to prevent code +Passing ``nowait=True`` or ``skip_locked=True`` to ``select_for_update()`` +using database backends that do not support these options, such as MySQL, will +cause a :exc:`~django.db.DatabaseError` to be raised. This prevents code from unexpectedly blocking. Evaluating a queryset with ``select_for_update()`` in autocommit mode on @@ -1580,6 +1583,10 @@ raised if ``select_for_update()`` is used in autocommit mode. ``select_for_update()`` you should use :class:`~django.test.TransactionTestCase`. +.. versionchanged:: 1.11 + + The ``skip_locked`` argument was added. + ``raw()`` ~~~~~~~~~ |
