mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #29229 -- Fixed column mismatch crash when combining two annotated values_list() querysets with union(), difference(), or intersection().
Regression in 7316720603821ebb64dfe8fa592ba6edcef5f3e.
This commit is contained in:
parent
cede5111bb
commit
a0c03c62a8
4 changed files with 20 additions and 2 deletions
|
@ -119,6 +119,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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue