diff options
Diffstat (limited to 'tests/aggregation')
| -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 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): """ |
