From a411b909671b7b8f8773af6b7cffa6992fe29138 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 23 Nov 2022 09:35:48 +0100 Subject: [PATCH] Refs #33050 -- Added test for QuerySet.count() on combined queries with select_related(). Thanks Simon Charette for noticing this. Fixed in 70499b25c708557fb9ee2264686cd172f4b2354e. --- tests/queries/test_qs_combinators.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py index 9d4988d6eb..6358e537ae 100644 --- a/tests/queries/test_qs_combinators.py +++ b/tests/queries/test_qs_combinators.py @@ -424,6 +424,12 @@ class QuerySetSetOperationTests(TestCase): qs = Number.objects.filter(pk__in=[]) self.assertEqual(qs.union(qs).count(), 0) + def test_count_union_with_select_related(self): + e1 = ExtraInfo.objects.create(value=1, info="e1") + Author.objects.create(name="a1", num=1, extra=e1) + qs = Author.objects.select_related("extra").order_by() + self.assertEqual(qs.union(qs).count(), 1) + @skipUnlessDBFeature("supports_select_difference") def test_count_difference(self): qs1 = Number.objects.filter(num__lt=10)