Ticket #34123: union-select-related-tests.diff

File union-select-related-tests.diff, 1.4 KB (added by Shai Berger, 19 months ago)

Tests to show and investigate the regression

  • tests/queries/test_qs_combinators.py

    diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py
    index 97b3f97b68..df98175b49 100644
    a b class QuerySetSetOperationTests(TestCase):  
    278278            operator.itemgetter("num"),
    279279        )
    280280
     281    def test_union_with_select_related_and_order(self):
     282        base_qs = Author.objects.select_related('extra').order_by()
     283        qs1 = base_qs.filter(name="a1")
     284        qs2 = base_qs.filter(name="a2")
     285        self.assertFalse(
     286            bool(
     287                qs1.union(qs2).order_by("pk")
     288            )
     289        )
     290
     291    def test_union_with_select_related_and_first(self):
     292        base_qs = Author.objects.select_related('extra')
     293        qs1 = base_qs.filter(name="a1")
     294        qs2 = base_qs.filter(name="a2")
     295        self.assertFalse(
     296            bool(
     297                qs1.union(qs2).first()
     298            )
     299        )
     300
     301    def test_union_with_first(self):
     302        base_qs = Author.objects.order_by()
     303        qs1 = base_qs.filter(name="a1")
     304        qs2 = base_qs.filter(name="a2")
     305        self.assertFalse(
     306            bool(
     307                qs1.union(qs2).first()
     308            )
     309        )
     310
    281311    def test_union_multiple_models_with_values_list_and_order(self):
    282312        reserved_name = ReservedName.objects.create(name="rn1", order=0)
    283313        qs1 = Celebrity.objects.all()
Back to Top