summaryrefslogtreecommitdiff
path: root/tests/aggregation
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2019-12-21 23:22:49 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-12-23 09:24:03 +0100
commit720de4d0441fcfdb543051389c70efbe66ed962a (patch)
tree46a2e2195b684dce0fe55116aaa477ba4f73d85c /tests/aggregation
parentcebd41e41603c3ca77c5b29d6cd20c1bff43827f (diff)
downloaddjango-720de4d0441fcfdb543051389c70efbe66ed962a.tar.gz
Fixed #31109 -- Disabled grouping by aliases on QuerySet.exists().
Clearing the SELECT clause in Query.has_results was orphaning GROUP BY references to it. Thanks Thierry Bastian for the report and Baptiste Mispelon for the bisect. Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80.
Diffstat (limited to 'tests/aggregation')
-rw-r--r--tests/aggregation/tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index ecbe81c151..dd30f57bed 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -1141,6 +1141,16 @@ class AggregateTestCase(TestCase):
# The GROUP BY should not be by alias either.
self.assertEqual(ctx[0]['sql'].lower().count('latest_book_pubdate'), 1)
+ def test_aggregation_subquery_annotation_exists(self):
+ latest_book_pubdate_qs = Book.objects.filter(
+ publisher=OuterRef('pk')
+ ).order_by('-pubdate').values('pubdate')[:1]
+ publisher_qs = Publisher.objects.annotate(
+ latest_book_pubdate=Subquery(latest_book_pubdate_qs),
+ count=Count('book'),
+ )
+ self.assertTrue(publisher_qs.exists())
+
@skipUnlessDBFeature('supports_subqueries_in_group_by')
def test_group_by_subquery_annotation(self):
"""