Subfieldbase removal causes unexpected behavioural in QS.values_list()
jenlu opened this issue · 2 comments
When correcting the deprecation of SubFieldBase (just removed it and added from_db_value
, works sort of) all is OK except a new unexpected behavior from QuerySet and values_list
.
Prior to this doing values_list(...)
on the query set returned something like:
[u'L', u'J', u'L' ]
but now it returns [([u'L'],), ([u'J'],), ([u'L'],)]
this is obviously as the to_python
returns a list (which is correct), but still, not sure why this ever worked in first place and how this can be changed now (on what level to override this to keep old behavioural).
Secondly the .values_list
on a multiselectfield is also open for possible interpretations, should it list values used or combination of values use ;-) but this is my problem...
Edit (by blag): Formatted with GFM
What version of Django did you notice this with?
According to the Travis results, this only happens with Django 1.6 & 1.7.
I'll try to fix that and push it later today.
This is a known Django bug #9619, and only happens for Django 1.6 and 1.7.
The workaround is to manually call .split(',')
on the returned result.
Because there really isn't a clean way to handle this, and it's fixed in Django 1.8+, I'm not going to spend any development time fixing this. I have updated the documentation to shine light on this bug and will be publishing that soon though.
If somebody has time to create a QuerySet
mixin that fixes this, I would adjusts the tests and accept that PR.