#12886: .aggregate() does not honour sliced queryset
------------------------------------------+---------------------------------
 Reporter:  t...@subnetz.org               |       Owner:  nobody    
   Status:  new                           |   Milestone:            
Component:  Database layer (models, ORM)  |     Version:  1.2-beta  
 Keywords:                                |       Stage:  Unreviewed
Has_patch:  0                             |  
------------------------------------------+---------------------------------
 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.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12886>
Django <http://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 django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to