﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19290	'exclude' on aggregations makes wrong SQL	letscan@…	nobody	"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)) .......
}}}

"	Uncategorized	closed	Database layer (models, ORM)	1.4	Normal	duplicate	aggregation		Unreviewed	0	0	0	0	0	0
