#27849: Support Postgres FILTER WHERE conditions in ArrayAgg
----------------------------------+--------------------------------------
Reporter: Tom | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Comment (by Tom):
I have added a completely basic, first-attempt at this here:
https://github.com/django/django/pull/8073
This currently works as described in the ticket above, but the code is not
optimal and is copied from our internal implementation. As this feature is
needed for the application I am working on I can continue to develop this,
but I have some questions:
Should this be an extension to `ArrayAgg` or a separate aggregate? If it
should be an extension, how can I change the `template` to add the `FILTER
(WHERE)` clause if required?
There doesn't seem to be an easy way to subclass `ArrayAgg` and add
elements to `data` or `params`, which is needed in this case. How could
this be achieved without duplicating the entire `as_sql` code as it is
currently? (it seems like the `as_sql` method should be broken up a bit, I
think?)
It would be quite nice to be able to pass a whole, full-fat `QuerySet`
into the aggregate, with the predicate that it is has been
`values_list`'ed and is a relation of the model being queried (i.e
`SomeModel.objects.annotate(foo=ArrayAgg('some_relation__id',
where=SomeRelation.objects.filter(parent=F('id')).values_list('xyz'))` or
somesuch. Is this even possible, or would it be chewing off too much?
--
Ticket URL: <https://code.djangoproject.com/ticket/27849#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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/061.2c8017110e2935b919c97e43b3718592%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.