From 3f32154f40a855afa063095e3d091ce6be21f2c5 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Fri, 8 Mar 2019 18:15:44 -0500 Subject: Refs #30188 -- Avoided GROUP BY when aggregating over non-aggregates. --- tests/expressions/tests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index a51080ef13..c19178b3ca 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -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): -- cgit v1.3