mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #12886 -- aggregation over sliced queryset
This commit is contained in:
parent
7d28bed13b
commit
7737305a4f
3 changed files with 14 additions and 7 deletions
|
@ -617,3 +617,11 @@ class BaseAggregateTestCase(TestCase):
|
|||
# Check internal state
|
||||
self.assertIsNone(annotated_books.query.alias_map["aggregation_book"].join_type)
|
||||
self.assertIsNone(excluded_books.query.alias_map["aggregation_book"].join_type)
|
||||
|
||||
def test_ticket12886(self):
|
||||
"""
|
||||
Check that aggregation over sliced queryset works correctly.
|
||||
"""
|
||||
qs = Book.objects.all().order_by('-rating')[0:3]
|
||||
vals = qs.aggregate(average_top3_rating=Avg('rating'))['average_top3_rating']
|
||||
self.assertAlmostEqual(vals, 4.5, places=2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue