Opened 7 years ago

Closed 6 years ago

Last modified 6 years 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 by Tim Graham, 7 years ago

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 by Matthew Pava, 7 years ago

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 by Tim Graham, 7 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Tom Forbes, 7 years ago

Cc: Tom Forbes added

comment:5 by Scott Halgrim, 6 years ago

Owner: changed from nobody to Scott Halgrim
Status: newassigned

comment:7 by Tom Forbes, 6 years ago

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 by Scott Halgrim, 6 years ago

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 6 years ago by Scott Halgrim (previous) (diff)

comment:10 by Tim Graham <timograham@…>, 6 years ago

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 by Tim Graham <timograham@…>, 6 years ago

In 926fa71:

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

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