mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
[1.8.x] Fixed #25377 -- Changed Count queries to execute COUNT(*) instead of COUNT('*').
Backport of 3fe3887a2e from master
This commit is contained in:
@@ -306,6 +306,12 @@ class BaseAggregateTestCase(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_fkey_aggregate(self):
|
||||
explicit = list(Author.objects.annotate(Count('book__id')))
|
||||
implicit = list(Author.objects.annotate(Count('book')))
|
||||
|
||||
Reference in New Issue
Block a user