diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2018-04-13 12:15:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-13 12:15:52 +0200 |
| commit | 0b66c3b442875627fa6daef4ac1e90900d74290b (patch) | |
| tree | 8adb83f8bde9e4e09315ed8d6e2cab5599a58f04 /tests | |
| parent | e1f13f15512ece2d8ea8c7bf9f704ce4286c2ffa (diff) | |
Fixed #29286 -- Fixed column mismatch crash with QuerySet.values() or values_list() after combining an annotated and unannotated queryset with union(), difference(), or intersection().
Regression in a0c03c62a8ac586e5be5b21393c925afa581efaf.
Thanks Tim Graham and Carlton Gibson for reviews.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/queries/test_qs_combinators.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py index e2ec18c034..8b02ab308b 100644 --- a/tests/queries/test_qs_combinators.py +++ b/tests/queries/test_qs_combinators.py @@ -1,4 +1,4 @@ -from django.db.models import F, IntegerField, Value +from django.db.models import Exists, F, IntegerField, OuterRef, Value from django.db.utils import DatabaseError, NotSupportedError from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature @@ -130,6 +130,14 @@ class QuerySetSetOperationTests(TestCase): ).values_list('num', 'count') self.assertCountEqual(qs1.union(qs2), [(1, 0), (2, 1)]) + def test_union_with_values_list_on_annotated_and_unannotated(self): + ReservedName.objects.create(name='rn1', order=1) + qs1 = Number.objects.annotate( + has_reserved_name=Exists(ReservedName.objects.filter(order=OuterRef('num'))) + ).filter(has_reserved_name=True) + qs2 = Number.objects.filter(num=9) + self.assertCountEqual(qs1.union(qs2).values_list('num', flat=True), [1, 9]) + def test_count_union(self): qs1 = Number.objects.filter(num__lte=1).values('num') qs2 = Number.objects.filter(num__gte=2, num__lte=3).values('num') |
