Opened 7 weeks ago

Last modified 3 weeks ago

#29317 new Cleanup/optimization

filter keyword undocumented in PostgreSQL aggregate functions

Reported by: Matthew Pava Owned by: nobody
Component: Documentation Version:
Severity: Normal Keywords: aggregate
Cc: Tom Forbes Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The signature for all of the aggregate functions for PostgreSQL includes a filter keyword argument, but I can't figure out what it is used for based on the documentation alone: https://docs.djangoproject.com/en/2.0/ref/contrib/postgres/aggregates/.

For what it's worth, I'm trying to filter out all of the empty values in an ArrayAgg expression, which seems to be a fairly common thing that one would want to do. Perhaps we could add an example to the documentation showing how that can be accomplished. I'm not sure right now if the filter keyword argument is the way to go.

Change History (4)

comment:1 Changed 7 weeks ago by Tim Graham

The relevant commit is b78d100fa62cd4fbbc70f2bae77c192cb36c1ccd. I don't think it makes much sense to repeat the documentation for filter in every aggregate subclass. Ideas?

comment:2 Changed 7 weeks ago by Matthew Pava

I agree. I just found the documentation here:
https://docs.djangoproject.com/en/2.0/topics/db/aggregation/#filtering-on-annotations
Honestly, though, even that little note seems a little buried in everything.

Maybe we can add a link to the generic aggregation documentation on the PostgreSQL aggregation documentation?
And, I think I found a bug. I keep getting this error when using a filter Q object with ArrayAgg:
AttributeError: 'WhereNode' object has no attribute '_output_field_or_none'

comment:3 Changed 6 weeks ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:4 Changed 3 weeks ago by Tom Forbes

Cc: Tom Forbes added
Note: See TracTickets for help on using tickets.
Back to Top