diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index a93c39e3d5..322db8ea1a 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1138,6 +1138,8 @@ class AggregateTestCase(TestCase): with self.assertNumQueries(1) as ctx: list(publisher_qs) self.assertEqual(ctx[0]['sql'].count('SELECT'), 2) + # The GROUP BY should not be by alias either. + self.assertEqual(ctx[0]['sql'].lower().count('latest_book_pubdate'), 1) @skipUnlessDBFeature('supports_subqueries_in_group_by') def test_group_by_subquery_annotation(self):