mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Refs #30188 -- Avoided GROUP BY when aggregating over non-aggregates.
This commit is contained in:
committed by
Tim Graham
parent
d1e9c25162
commit
3f32154f40
@@ -551,7 +551,6 @@ class BasicExpressionsTests(TestCase):
|
||||
)
|
||||
self.assertEqual(qs.get().float, 1.2)
|
||||
|
||||
@skipUnlessDBFeature('supports_subqueries_in_group_by')
|
||||
def test_aggregate_subquery_annotation(self):
|
||||
with self.assertNumQueries(1) as ctx:
|
||||
aggregate = Company.objects.annotate(
|
||||
@@ -566,7 +565,11 @@ class BasicExpressionsTests(TestCase):
|
||||
self.assertEqual(aggregate, {'ceo_salary_gt_20': 1})
|
||||
# Aggregation over a subquery annotation doesn't annotate the subquery
|
||||
# twice in the inner query.
|
||||
self.assertLessEqual(ctx.captured_queries[0]['sql'].count('SELECT'), 4,)
|
||||
sql = ctx.captured_queries[0]['sql']
|
||||
self.assertLessEqual(sql.count('SELECT'), 3)
|
||||
# GROUP BY isn't required to aggregate over a query that doesn't
|
||||
# contain nested aggregates.
|
||||
self.assertNotIn('GROUP BY', sql)
|
||||
|
||||
def test_explicit_output_field(self):
|
||||
class FuncA(Func):
|
||||
|
||||
Reference in New Issue
Block a user