Opened 6 years ago

Closed 5 years ago

#30572 closed Bug (fixed)

Composed queries cannot change the list of columns with values()/values_list().

Reported by: Mariusz Felisiak Owned by: Mariusz Felisiak
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Composed queries cannot change the list of columns when values()/values_list() is evaluated multiple times, e.g.

>>> ReservedName.objects.create(name='a', order=2)
>>> qs1 = ReservedName.objects.all()
>>> print(qs1.union(qs1).values_list('name', 'order').get())
('a', 2)
>>> print(qs1.union(qs1).values_list('order').get())
('a', 2)

(see compiler.py#L428-L433).

Attachments (1)

30572.diff (695 bytes ) - added by Mariusz Felisiak 6 years ago.

Download all attachments as: .zip

Change History (6)

by Mariusz Felisiak, 6 years ago

Attachment: 30572.diff added

comment:1 by Mariusz Felisiak, 6 years ago

Has patch: set

comment:2 by Carlton Gibson, 6 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by GitHub <noreply@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 14d026cc:

Fixed #30572 -- Prevented values()/values_list() on combined queryset from mutating the list of columns in querysets.

comment:4 by lieryan, 5 years ago

Resolution: fixed
Status: closednew
Version: master2.2

I can confirm that I can reproduce this bug in the latest LTS version Django 2.2 as well, is there a chance for this bugfix to be backported to 2.2? The current patch should apply cleanly in stable/2.2.x.

comment:5 by Mariusz Felisiak, 5 years ago

Resolution: fixed
Status: newclosed
Version: 2.2master

This patch doesn't qualify for a backport. Please don't reopen closed tickets.

Note: See TracTickets for help on using tickets.
Back to Top