Fixed #25377 -- Changed Count queries to execute COUNT(*) instead of COUNT('*').

This commit is contained in:
Adam Chainz 2015-09-10 17:07:09 +01:00 committed by Tim Graham
parent 4d933ad418
commit 3fe3887a2e
6 changed files with 33 additions and 14 deletions

View file

@ -405,6 +405,12 @@ class AggregateTestCase(TestCase):
vals = Book.objects.aggregate(Count("rating", distinct=True))
self.assertEqual(vals, {"rating__count": 4})
def test_count_star(self):
with self.assertNumQueries(1) as ctx:
Book.objects.aggregate(n=Count("*"))
sql = ctx.captured_queries[0]['sql']
self.assertIn('SELECT COUNT(*) ', sql)
def test_non_grouped_annotation_not_in_group_by(self):
"""
An annotation not included in values() before an aggregate should be