diff options
| author | Amr Anwar <amranwar945@gmail.com> | 2018-03-19 09:58:50 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-03-19 21:06:40 -0400 |
| commit | c5bb472095f02df364f9a0ce64f0b97bfd4a8c63 (patch) | |
| tree | 6194618c94e702c9e244a046a02a62fa73a9dbe9 /tests | |
| parent | cd4275f8d70a9bab43c4b9f5a2c8007b86765373 (diff) | |
[1.11.x] Fixed #29229 -- Fixed column mismatch crash when combining two annotated values_list() querysets with union(), difference(), or intersection().
Regression in 7316720603821ebb64dfe8fa592ba6edcef5f3e.
Backport of a0c03c62a8ac586e5be5b21393c925afa581efaf from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/queries/test_qs_combinators.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py index 3450014d94..9083520c24 100644 --- a/tests/queries/test_qs_combinators.py +++ b/tests/queries/test_qs_combinators.py @@ -128,6 +128,17 @@ class QuerySetSetOperationTests(TestCase): reserved_name = qs1.union(qs1).values_list('name', 'order', 'id').get() self.assertEqual(reserved_name[:2], ('a', 2)) + def test_union_with_two_annotated_values_list(self): + qs1 = Number.objects.filter(num=1).annotate( + count=Value(0, IntegerField()), + ).values_list('num', 'count') + qs2 = Number.objects.filter(num=2).values('pk').annotate( + count=F('num'), + ).annotate( + num=Value(1, IntegerField()), + ).values_list('num', 'count') + self.assertCountEqual(qs1.union(qs2), [(1, 0), (2, 1)]) + 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') |
