summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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 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):
"""