#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 , 7 years ago
comment:2 by , 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 , 7 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 7 years ago
Cc: | added |
---|
comment:5 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:7 by , 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 , 6 years ago
Oh I'm sorry guys. 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
The relevant commit is b78d100fa62cd4fbbc70f2bae77c192cb36c1ccd. I don't think it makes much sense to repeat the documentation for
filter
in every aggregate subclass. Ideas?