diff options
| author | Simon Charette <charette.s@gmail.com> | 2019-12-21 23:22:49 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-12-23 09:24:37 +0100 |
| commit | 7b065c41e406fb22d39d1f7b4cfed96bf06dc591 (patch) | |
| tree | cb27aed8fbce0cf6d0a14c0239538e6d570144e4 /tests | |
| parent | b1a309f6f08bc27c7d843b7be493282a2b0ac8fe (diff) | |
[3.0.x] 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.
Backport of 720de4d0441fcfdb543051389c70efbe66ed962a from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/aggregation/tests.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 5ba2e180e0..efc0a72c86 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1139,6 +1139,16 @@ class AggregateTestCase(TestCase): list(publisher_qs) self.assertEqual(ctx[0]['sql'].count('SELECT'), 2) + 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): """ |
