#35444: Add generic support for order by to Aggregate
-------------------------------------+-------------------------------------
Reporter: Chris M | Owner: Chris M
Type: New | Status: assigned
feature |
Component: Database | Version: dev
layer (models, ORM) | Keywords: orderableaggmixin
Severity: Normal | aggregate
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
We would like to add general support for ordering within SQL aggregate
functions that allow it. Currently, this behavior is only supported in
PostgreSQL via the `OrderableAggMixin`. With changes made in #35339 , it
should be possible to merge the behaviors of that mixin into the core
behaviors of the `Aggregate` class and then apply it to functions that
support order by like Sqlite's `STRING_AGG`, MySQL's `GROUP_CONCAT`, and
Oracle's `LIST_AGG WITHIN GROUP (ORDER BY)`.
These are some implementation notes from Simon discussed on the original
bug ticket in this comment ticket:35339#comment:13 that I'm capturing some
of here to avoid jumping around.
> A few things I believe we should focus on along the way
> 1. We should make the argument Aggregate(order_by) instead of ordering
to be consistent with Window
> 2. Just like we do with allow_distinct we should use a allow_order_by
attribute for aggregates that support this feature
> 3. We should make OrderableAggMixin a shim that sets
allow_order_by=True, redirect __init__(ordering) to order_by, and emit a
deprecation warning when doing so to allow a proper transition for
contrib.postgres.ArrayAgg and friends
> 4. We should reuse OrderByList as much as possible
--
Ticket URL: <https://code.djangoproject.com/ticket/35444>
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/0107018f67d9701b-a3d9abc2-3f4c-44d6-b54f-91f34115949d-000000%40eu-central-1.amazonses.com.