From 77278929c86168f075600d9d8c8e76a4792e672b Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Fri, 15 Dec 2023 21:00:59 -0500 Subject: Fixed #35042 -- Fixed a count() crash on combined queries. Regression in 59bea9efd2768102fc9d3aedda469502c218e9b7. Thanks Marcin for the report. --- tests/aggregation/tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 62e9c6a27a..4408535228 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -2344,3 +2344,18 @@ class AggregateAnnotationPruningTests(TestCase): max_book_author=Max("book__authors"), ).aggregate(count=Count("id", filter=Q(id__in=[F("max_book_author"), 0]))) self.assertEqual(aggregates, {"count": 1}) + + def test_aggregate_combined_queries(self): + # Combined queries could have members in their values select mask while + # others have them in their annotation mask which makes annotation + # pruning complex to implement hence why it's not implemented. + qs = Author.objects.values( + "age", + other=Value(0), + ).union( + Book.objects.values( + age=Value(0), + other=Value(0), + ) + ) + self.assertEqual(qs.count(), 3) -- cgit v1.3