#35339: Ordering and filtering a Postgres ArrayAgg with parameters inverts SQL
param order
-------------------------------------+-------------------------------------
     Reporter:  Chris M              |                    Owner:  Chris M
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  postgres arrayagg    |             Triage Stage:  Ready for
  ordering                           |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

 Hello Chris, glad to hear you're interested in moving this forward! We
 should definitely create a new ticket for that.

 I'd suggest targeting `StringAgg(Aggregate)` and default to using
 `STRING_AGG` (Postgres, SQLite), `GROUP_CONCAT` as fallback on MySQL, and
 `LIST_AGG WITHIN GROUP (ORDER BY)` on Oracle.

 As for whether `StringAgg` should live in `models.aggregate` (or only in
 tests at first) I think it could even if that means documenting it.
 Another potential candidate that could be added is `JSONArrayAgg` but I
 think we should focus on a single one for this first ticket.

 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

 If that can be of any help
 [https://github.com/charettes/django/commits/ticket-35339-generic-order-
 by-aggregate/ I hacked a bit on it a few days ago to make sure I didn't
 send through a rabbit hole] by requesting these
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35339#comment:13>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f57baf96f-2615aa72-a530-471b-9133-56167532ae2f-000000%40eu-central-1.amazonses.com.

Reply via email to