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/ref/models | |
| parent | 060576b0abac460d72714e300aa709d1e7a87dd7 (diff) | |
Fixed #31573 -- Made QuerySet.update() respect ordering on MariaDB/MySQL.
Diffstat (limited to 'docs/ref/models')
| -rw-r--r-- | docs/ref/models/querysets.txt | 15 |
1 files changed, 15 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()`` ~~~~~~~~~~~~ |
