Refs #33050 -- Added test for QuerySet.count() on combined queries with select_related().

Thanks Simon Charette for noticing this.

Fixed in 70499b25c7.
This commit is contained in:
Mariusz Felisiak 2022-11-23 09:35:48 +01:00 committed by GitHub
parent 4035bab56f
commit a411b90967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -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)