diff options
| author | Ramiro Morales <ramiro@users.noreply.github.com> | 2018-09-13 13:29:48 -0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-09-13 12:29:48 -0400 |
| commit | 1b1f64ee5a78cc217fead52cbae23114502cf564 (patch) | |
| tree | c6baf64db6c3b7a381fd45639b189ef072e4a960 /docs | |
| parent | c52ecbda615594750ae59b789313a29893950b3d (diff) | |
Refs #14357 -- Deprecated Meta.ordering affecting GROUP BY queries.
Thanks Ramiro Morales for contributing to the patch.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/internals/deprecation.txt | 2 | ||||
| -rw-r--r-- | docs/ref/models/options.txt | 3 | ||||
| -rw-r--r-- | docs/releases/2.2.txt | 9 | ||||
| -rw-r--r-- | docs/topics/db/aggregation.txt | 7 |
4 files changed, 20 insertions, 1 deletions
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index d7b02fa3bc..7043391527 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -19,6 +19,8 @@ details on these changes. * ``django.core.paginator.QuerySetPaginator`` will be removed. +* A model's ``Meta.ordering`` will no longer affect ``GROUP BY`` queries. + .. _deprecation-removed-in-3.0: 3.0 diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt index 246f3e7d9a..3994e408a5 100644 --- a/docs/ref/models/options.txt +++ b/docs/ref/models/options.txt @@ -285,7 +285,8 @@ Django quotes column and table names behind the scenes. ordering = [F('author').asc(nulls_last=True)] Default ordering also affects :ref:`aggregation queries - <aggregation-ordering-interaction>`. + <aggregation-ordering-interaction>` but this won't be the case starting + in Django 3.1. .. warning:: diff --git a/docs/releases/2.2.txt b/docs/releases/2.2.txt index af2910a514..bf5bc30cde 100644 --- a/docs/releases/2.2.txt +++ b/docs/releases/2.2.txt @@ -289,6 +289,15 @@ Miscellaneous Features deprecated in 2.2 ========================== +Model ``Meta.ordering`` will no longer affect ``GROUP BY`` queries +------------------------------------------------------------------ + +A model's ``Meta.ordering`` affecting ``GROUP BY`` queries (such as +``.annotate().values()``) is a common source of confusion. Such queries now +issue a deprecation warning with the advice to add an ``order_by()`` to retain +the current query. ``Meta.ordering`` will be ignored in such queries starting +in Django 3.1. + Miscellaneous ------------- diff --git a/docs/topics/db/aggregation.txt b/docs/topics/db/aggregation.txt index 50a92a5dbe..c709c064a5 100644 --- a/docs/topics/db/aggregation.txt +++ b/docs/topics/db/aggregation.txt @@ -514,6 +514,13 @@ include the aggregate column. Interaction with default ordering or ``order_by()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. deprecated:: 2.2 + + Starting in Django 3.1, the ordering from a model's ``Meta.ordering`` won't + be used in ``GROUP BY`` queries, such as ``.annotate().values()``. Since + Django 2.2, these queries issue a deprecation warning indicating to add an + explicit ``order_by()`` to the queryset to silence the warning. + Fields that are mentioned in the ``order_by()`` part of a queryset (or which are used in the default ordering on a model) are used when selecting the output data, even if they are not otherwise specified in the ``values()`` |
