diff options
| author | Ran Benita <ran234@gmail.com> | 2017-10-17 11:28:00 +0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-10-28 21:42:51 -0400 |
| commit | 6b5f2e3b7951c7cb27a316779e9dbdf12bd95726 (patch) | |
| tree | 2cd88e204f581f8a4e97febc656831e49cce9486 /docs | |
| parent | 5630f4e6acba6359d7d182de034a6af563025df9 (diff) | |
[2.0.x] Refs #28010 -- Allowed reverse related fields in SELECT FOR UPDATE .. OF.
Thanks Adam Chidlow for polishing the patch.
Backport of 03049fb8d96ccd1f1ed0285486103542de42faba from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/querysets.txt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 81caf97aa7..0b6e53ed1b 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1650,6 +1650,19 @@ specify the related objects you want to lock in ``select_for_update(of=(...))`` using the same fields syntax as :meth:`select_related`. Use the value ``'self'`` to refer to the queryset's model. +You can't use ``select_for_update()`` on nullable relations:: + + >>> Person.objects.select_related('hometown').select_for_update() + Traceback (most recent call last): + ... + django.db.utils.NotSupportedError: FOR UPDATE cannot be applied to the nullable side of an outer join + +To avoid that restriction, you can exclude null objects if you don't care about +them:: + + >>> Person.objects.select_related('hometown').select_for_update().exclude(hometown=None) + <QuerySet [<Person: ...)>, ...]> + Currently, the ``postgresql``, ``oracle``, and ``mysql`` database backends support ``select_for_update()``. However, MySQL doesn't support the ``nowait``, ``skip_locked``, and ``of`` arguments. |
