Opened 6 days ago
Last modified 44 hours ago
#36288 assigned Bug
Regression in values_list() with duplicated field names
According to the ticket's flags, the next step(s) to move this issue forward are:
- For a Django committer to do a final review of the patch and merge it if all looks good.
Change History (5)
comment:1 by , 6 days ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 6 days ago
Owner: | set to |
---|---|
Status: | new → assigned |
This is effectively a regression caused by #28900 (65ad4ade74dc9208b9d686a451cd6045df0c9c3a) as sql.Query.selected
is now a dict[alias, Expression]
and since values_list
defaults to using the provided strings as field names they get considered to be a single one.
We'll most likely have to generate an alias for the existing members with colliding names.
comment:3 by , 6 days ago
Has patch: | set |
---|
comment:4 by , 6 days ago
Thanks for the quick reaction! FWIW, the use case that revealed this was a QuerySet to produce tuples for form choices where the value and the verbose parts were identical.
comment:5 by , 44 hours ago
Triage Stage: | Accepted → Ready for checkin |
---|
Thank you Claude for the report! I have reproduced with the following:
Versus:
Now, I'm not sure this is a bug? I mean there is certainly a change in behavior, but to me the 5.1 result feels "buggy", so in a way this "was fixed" in 5.2.
On the other hand, the DB query does duplicate the columns so perhaps this *is* a regression:
Claude, could you indulge me and share in the ticket the use case for getting the repeated fields in the
values_list
result? Accepting in the meantime.