#19290: 'exclude' on aggregations makes wrong SQL
----------------------------------------------+-------------------------
Reporter: letscan@… | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: 1.4
Severity: Normal | Keywords: aggregation
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+-------------------------
I have a query like this:
{{{
qs.annotate(num_a=Sum(field1), num_b=Sum(field2)).exclude(num_a=0,
num_b=0)
}}}
the query returns fewer objects than expected. I have checked the SQL of
the query and found it is wrong:
{{{
SELECT ......... HAVING (NOT SUM(field1)=0 AND NOT SUM(field2)=0) .......
}}}
while what I want is like (just as the
[https://docs.djangoproject.com/en/1.4/ref/models/querysets/#exclude
documentation] says):
{{{
SELECT ......... HAVING (NOT (SUM(field1)=0 AND SUM(field2)=0)) .......
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19290>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.