﻿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
12886	.aggregate() does not honour sliced queryset	til@…	Anssi Kääriäinen <akaariai@…>	"If I aggregate a sliced queryset, the result is an aggregate across the whole unsliced queryset:

{{{
In [97]: qs = Encounter.objects.all()

In [98]: qs.aggregate(**aggregations)
Out[98]: {'total_no_of_adults': 19, 'total_no_of_children': 8, 'total_no_of_dogs': 2}

In [99]: qs[0:5].aggregate(**aggregations)
Out[99]: {'total_no_of_adults': 19, 'total_no_of_children': 8, 'total_no_of_dogs': 2}
}}}

It works though if .annotate() is called first, even if no annotations are given:

{{{
In [100]: qs[0:5].annotate().aggregate(**aggregations)
Out[100]: {'total_no_of_adults': 8, 'total_no_of_children': 8, 'total_no_of_dogs': 2}
}}}

The latter are the correct figures for my example model."	Bug	closed	Database layer (models, ORM)	1.4	Normal	fixed	aggregate	3point2 Filip Gruszczyński	Accepted	0	0	0	0	0	0
