diff options
| author | davidchorpash <dchorpash@doctorondemand.com> | 2020-06-19 22:55:03 -0600 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-07-08 11:43:50 +0200 |
| commit | 779e615e362108862f1681f965ee9e4f1d0ae6d2 (patch) | |
| tree | 631a909a539adf33193a5dc1d6d5ee086d11be6e /docs | |
| parent | 060576b0abac460d72714e300aa709d1e7a87dd7 (diff) | |
Fixed #31573 -- Made QuerySet.update() respect ordering on MariaDB/MySQL.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/querysets.txt | 15 | ||||
| -rw-r--r-- | docs/releases/3.2.txt | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index d70f7deca3..6edc508661 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -2530,6 +2530,21 @@ update a bunch of records for a model that has a custom e.comments_on = False e.save() +Ordered queryset +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.2 + +Chaining ``order_by()`` with ``update()`` is supported only on MariaDB and +MySQL, and is ignored for different databases. This is useful for updating a +unique field in the order that is specified without conflicts. For example:: + + Entry.objects.order_by('-number').update(number=F('number') + 1) + +.. note:: + + If the ``order_by()`` clause contains annotations, it will be ignored. + ``delete()`` ~~~~~~~~~~~~ diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt index 88c4cdc998..6c49cf5375 100644 --- a/docs/releases/3.2.txt +++ b/docs/releases/3.2.txt @@ -224,6 +224,9 @@ Models * The new :attr:`.UniqueConstraint.opclasses` attribute allows setting PostgreSQL operator classes. +* The :meth:`.QuerySet.update` method now respects the ``order_by()`` clause on + MySQL and MariaDB. + Requests and Responses ~~~~~~~~~~~~~~~~~~~~~~ |
