diff options
| author | Floris den Hengst <florisdenhengst@gmail.com> | 2016-07-05 11:47:24 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-06-28 20:29:33 -0400 |
| commit | 96199e562dcc409ab4bdc2b2146fa7cf73c7c5fe (patch) | |
| tree | cb047cbe692bfe22a10b25b1336730079ec027bf /docs | |
| parent | 2a0116266c4d81bd1cc4e3ea20efe9a7874f481b (diff) | |
Fixed #26067 -- Added ordering support to ArrayAgg and StringAgg.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/postgres/aggregates.txt | 31 | ||||
| -rw-r--r-- | docs/releases/2.2.txt | 5 |
2 files changed, 33 insertions, 3 deletions
diff --git a/docs/ref/contrib/postgres/aggregates.txt b/docs/ref/contrib/postgres/aggregates.txt index 480c230c40..a605bc831c 100644 --- a/docs/ref/contrib/postgres/aggregates.txt +++ b/docs/ref/contrib/postgres/aggregates.txt @@ -22,7 +22,7 @@ General-purpose aggregation functions ``ArrayAgg`` ------------ -.. class:: ArrayAgg(expression, distinct=False, filter=None, **extra) +.. class:: ArrayAgg(expression, distinct=False, filter=None, ordering=(), **extra) Returns a list of values, including nulls, concatenated into an array. @@ -31,6 +31,22 @@ General-purpose aggregation functions An optional boolean argument that determines if array values will be distinct. Defaults to ``False``. + .. attribute:: ordering + + .. versionadded:: 2.2 + + An optional string of a field name (with an optional ``"-"`` prefix + which indicates descending order) or an expression (or a tuple or list + of strings and/or expressions) that specifies the ordering of the + elements in the result list. + + Examples:: + + 'some_field' + '-some_field' + from django.db.models import F + F('some_field').desc() + ``BitAnd`` ---------- @@ -73,7 +89,7 @@ General-purpose aggregation functions ``StringAgg`` ------------- -.. class:: StringAgg(expression, delimiter, distinct=False, filter=None) +.. class:: StringAgg(expression, delimiter, distinct=False, filter=None, ordering=()) Returns the input values concatenated into a string, separated by the ``delimiter`` string. @@ -87,6 +103,17 @@ General-purpose aggregation functions An optional boolean argument that determines if concatenated values will be distinct. Defaults to ``False``. + .. attribute:: ordering + + .. versionadded:: 2.2 + + An optional string of a field name (with an optional ``"-"`` prefix + which indicates descending order) or an expression (or a tuple or list + of strings and/or expressions) that specifies the ordering of the + elements in the result string. + + Examples are the same as for :attr:`ArrayAgg.ordering`. + Aggregate functions for statistics ================================== diff --git a/docs/releases/2.2.txt b/docs/releases/2.2.txt index 840d4b4d0d..742f4893be 100644 --- a/docs/releases/2.2.txt +++ b/docs/releases/2.2.txt @@ -70,7 +70,10 @@ Minor features :mod:`django.contrib.postgres` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -* ... +* The new ``ordering`` argument for + :class:`~django.contrib.postgres.aggregates.ArrayAgg` and + :class:`~django.contrib.postgres.aggregates.StringAgg` determines the + ordering of the aggregated elements. :mod:`django.contrib.redirects` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
