Re: [Feature Request] Shorthand syntax for filtering aggregations

2017-04-17 Thread charettes
Hey Tom, Overriding Aggregate.as_sql() to branch on connection.features to build the FILTER clause shouldn't be an issue. I think you could rely on super().as_sql(..., filter=filter_sql) extra parameter when the connection supports the FILTER statement and fallback to self.clone(), clone.source

Re: [Feature Request] Shorthand syntax for filtering aggregations

2017-04-17 Thread Tom Forbes
Hey Simon, Thanks for your reply, I actually agree after thinking about it. Adding a filter/exclude method and getting it to work correctly in the way people would expect is be pretty complex. Adding an argument that takes a Q object would suffice for now at least. I'm happy to implement this, but

Re: [Feature Request] Shorthand syntax for filtering aggregations

2017-04-16 Thread charettes
Hello Tom, Thanks for working on adding filter support to aggregate. I think adding support for the SQL:2003 features on all aggregates by emulating it on backends that don't support it using CASE makes a lot of sense[0]. As I've mentioned on your PR this is syntactic sugar I've been missing from

Re: [Feature Request] Shorthand syntax for filtering aggregations

2017-04-12 Thread Ian Foote
Hi Tom, I really like the look of Count('emails').filter(unread=False) in the annotate call. Ian On 12/04/17 21:35, Tom Forbes wrote: > Hello, > At the Djangocon sprints I wanted to add support for a postgres specific > syntax for filtering aggregations, which is quite simple: MAX(something) > F

[Feature Request] Shorthand syntax for filtering aggregations

2017-04-12 Thread Tom Forbes
Hello, At the Djangocon sprints I wanted to add support for a postgres specific syntax for filtering aggregations, which is quite simple: MAX(something) FILTER (WHERE x=1). During this the sprints I was told that it would be good to support this for all databases, and it can be done using the CASE