diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-12-02 07:57:19 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-12-02 07:58:44 +0100 |
| commit | 6cf3b6f5cf0cc3b11e86e511ec5201999913286f (patch) | |
| tree | 7c4c08f951923bb03efffff6c8639b530073d9b7 /docs | |
| parent | 9a17ae50c61a3a0ea6c552ce4e3eab27f796d094 (diff) | |
[2.2.x] Fixed #30953 -- Made select_for_update() lock queryset's model when using "self" with multi-table inheritance.
Thanks Abhijeet Viswa for the report and initial patch.
Backport of 0107e3d1058f653f66032f7fd3a0bd61e96bf782 from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/querysets.txt | 8 | ||||
| -rw-r--r-- | docs/releases/2.2.8.txt | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 3ccd5958fd..f23d4bc598 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1696,6 +1696,14 @@ 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. +.. admonition:: Lock parents models in ``select_for_update(of=(...))`` + + If you want to lock parents models when using :ref:`multi-table inheritance + <multi-table-inheritance>`, you must specify parent link fields (by default + ``<parent_model_name>_ptr``) in the ``of`` argument. For example:: + + Restaurant.objects.select_for_update(of=('self', 'place_ptr')) + You can't use ``select_for_update()`` on nullable relations:: >>> Person.objects.select_related('hometown').select_for_update() diff --git a/docs/releases/2.2.8.txt b/docs/releases/2.2.8.txt index 4d8f9869c5..3c5eb5c754 100644 --- a/docs/releases/2.2.8.txt +++ b/docs/releases/2.2.8.txt @@ -17,3 +17,9 @@ Bugfixes * Fixed a regression in Django 2.2.1 that caused a crash when migrating permissions for proxy models with a multiple database setup if the ``default`` entry was empty (:ticket:`31021`). + +* Fixed a data loss possibility in the + :meth:`~django.db.models.query.QuerySet.select_for_update()`. When using + ``'self'`` in the ``of`` argument with :ref:`multi-table inheritance + <multi-table-inheritance>`, a parent model was locked instead of the + queryset's model (:ticket:`30953`). |
