1
0
mirror of https://github.com/django/django.git synced 2024-12-24 10:05:46 +00:00

Corrected an aggregation test failure under PostgreSQL, introduced by r15223. Thanks to Alex for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15230 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2011-01-17 02:37:40 +00:00
parent 1ebd6860b6
commit 964cf1be86

View File

@ -479,19 +479,19 @@ class AggregationTests(TestCase):
# age is a field on Author, so it shouldn't be allowed as an aggregate.
# But age isn't included in the ValuesQuerySet, so it is.
results = Author.objects.values('name').annotate(age=Count('book_contact_set'))
results = Author.objects.values('name').annotate(age=Count('book_contact_set')).order_by('name')
self.assertEquals(len(results), 9)
self.assertEquals(results[0]['name'], u'Adrian Holovaty')
self.assertEquals(results[0]['age'], 1)
# Same problem, but aggregating over m2m fields
results = Author.objects.values('name').annotate(age=Avg('friends__age'))
results = Author.objects.values('name').annotate(age=Avg('friends__age')).order_by('name')
self.assertEquals(len(results), 9)
self.assertEquals(results[0]['name'], u'Adrian Holovaty')
self.assertEquals(results[0]['age'], 32.0)
# Same problem, but colliding with an m2m field
results = Author.objects.values('name').annotate(friends=Count('friends'))
results = Author.objects.values('name').annotate(friends=Count('friends')).order_by('name')
self.assertEquals(len(results), 9)
self.assertEquals(results[0]['name'], u'Adrian Holovaty')
self.assertEquals(results[0]['friends'], 2)