Ticket #29286: 29286.diff

File 29286.diff, 1.2 KB (added by Mariusz Felisiak, 7 years ago)

Regression test.

  • tests/queries/test_qs_combinators.py

    diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py
    index e2ec18c034..32300fd985 100644
    a b  
    1 from django.db.models import F, IntegerField, Value
     1from django.db.models import Exists, F, IntegerField, OuterRef, Value
    22from django.db.utils import DatabaseError, NotSupportedError
    33from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
    44
    class QuerySetSetOperationTests(TestCase):  
    130130        ).values_list('num', 'count')
    131131        self.assertCountEqual(qs1.union(qs2), [(1, 0), (2, 1)])
    132132
     133    def test_union_with_two_annotated_queries(self):
     134        ReservedName.objects.create(name='rn1', order=1)
     135        qs1 = Number.objects.annotate(
     136            has_reserved_name=Exists(ReservedName.objects.filter(order=OuterRef('num')))
     137        ).filter(has_reserved_name=True)
     138        qs2 = Number.objects.filter(num=9)
     139        self.assertCountEqual(qs1.union(qs2).values_list('num', flat=True), [1, 9])
     140
    133141    def test_count_union(self):
    134142        qs1 = Number.objects.filter(num__lte=1).values('num')
    135143        qs2 = Number.objects.filter(num__gte=2, num__lte=3).values('num')
Back to Top