Opened 9 months ago

Closed 7 weeks ago

Last modified 7 weeks ago

#29317 closed Cleanup/optimization (fixed)

filter keyword undocumented in PostgreSQL aggregate functions

Reported by: Matthew Pava Owned by: Scott Halgrim
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 (10)

comment:1 Changed 9 months 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 9 months 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 9 months ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:4 Changed 8 months ago by Tom Forbes

Cc: Tom Forbes added

comment:5 Changed 3 months ago by Scott Halgrim

Owner: changed from nobody to Scott Halgrim
Status: newassigned

comment:7 Changed 3 months ago by Tom Forbes

Hey shalgrim, can you make a pull request to the Django project with this? If you visit https://github.com/django/django you should see a button to do this

comment:9 Changed 3 months ago by Scott Halgrim

Oh I'm sorry folks. Two things. I had meant to link to my PR before: https://github.com/django/django/pull/10530

And I just saw Tom's comment right now.

Again, sorry for the confusion. Thanks, Vishavjit

Last edited 3 months ago by Scott Halgrim (previous) (diff)

comment:10 Changed 7 weeks ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 7e9d5a0a:

[2.1.x] Fixed #29317 -- Doc'd filter argument in contrib.postgres aggregates.

Backport of 926fa7116fd633b69277c3ad9b3370ca45163231 from master.

comment:11 Changed 7 weeks ago by Tim Graham <timograham@…>

In 926fa71:

Fixed #29317 -- Doc'd filter argument in contrib.postgres aggregates.

Note: See TracTickets for help on using tickets.
Back to Top