Hi all,
There is a behaviour change in Django 5.2 but I’m posting here rather than filing a bug because I may have been previously relying on unsupported behaviour. I have query which does boils down to this:
qs = models.Employee.objects.values_list(‘username’, ‘username’, ‘company__legal_name’)
Notice the repeated “username”. On Django 5.1.6 and 5.1.7, each result from the queryset is a 3-tuple whereas on 5.2 this is a 2-tuple. I suspect this is related to the change mention in the release notes which reads:
The
SELECT
clause generated when usingQuerySet.values()
andQuerySet.values_list()
now matches the specified order of the referenced expressions. Previously, the order was based on a set of counterintuitive rules which made query combination through methods such asQuerySet.union()
unpredictable.
So, should I fix my code to handle the duplicate case, or is this a bug?
Thanks, Shaheed