#31687: Subquery loses ordering when passed to Func even if Func needs ordering.
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):
* status: new => closed
* resolution: => invalid
Comment:
IMO you should use `ArrayAgg` (`ARRAY_AGG`) instead of `ARRAY` which is
perfect for your use case and supports ordering. For example:
{{{
from django.contrib.postgres.aggregates import ArrayAgg
Article.objects.annotate(
authors_by_age=ArrayAgg('authors__name', ordering=F('authors__age')),
)
}}}
Database functions that allow subqueries and depend on ordering in most of
cases support separate `ORDER BY` clauses.
--
Ticket URL: <https://code.djangoproject.com/ticket/31687#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/069.42bdb61b67fb1be82a7775db980194f1%40djangoproject.com.