Skip to content

Commit

Permalink
[1.2.X] Corrected an aggregation test failure under PostgreSQL, intro…
Browse files Browse the repository at this point in the history
…duced by r15223. Thanks to Alex for the report.

Backport of r15230 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15231 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Jan 17, 2011
1 parent 0866dc1 commit aeddab3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/regressiontests/aggregation_regress/tests.py
Expand Up @@ -500,19 +500,19 @@ def test_values_queryset_non_conflict(self):


# age is a field on Author, so it shouldn't be allowed as an aggregate. # 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. # 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(len(results), 9)
self.assertEquals(results[0]['name'], u'Adrian Holovaty') self.assertEquals(results[0]['name'], u'Adrian Holovaty')
self.assertEquals(results[0]['age'], 1) self.assertEquals(results[0]['age'], 1)


# Same problem, but aggregating over m2m fields # 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(len(results), 9)
self.assertEquals(results[0]['name'], u'Adrian Holovaty') self.assertEquals(results[0]['name'], u'Adrian Holovaty')
self.assertEquals(results[0]['age'], 32.0) self.assertEquals(results[0]['age'], 32.0)


# Same problem, but colliding with an m2m field # 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(len(results), 9)
self.assertEquals(results[0]['name'], u'Adrian Holovaty') self.assertEquals(results[0]['name'], u'Adrian Holovaty')
self.assertEquals(results[0]['friends'], 2) self.assertEquals(results[0]['friends'], 2)
Expand Down

0 comments on commit aeddab3

Please sign in to comment.