QuerySet.values_list returns extra fields in Oracle
|Reported by:||Ian Kelly||Owned by:||Malcolm Tredinnick|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
values_list queries are failing in Oracle with results like this one:
Failed example: Article.objects.values_list('headline') Expected: [(u'Article 5',), (u'Article 6',), (u'Article 4',), (u'Article 2',), (u'Article 3',), (u'Article 7',), (u'Article 1',)] Got: [[u'Article 5', u'', None], [u'Article 6', u'', None], [u'Article 4', u'', None], [u'Article 2', u'', None], [u'Article 3', u'', None], [u'Article 7', u'', None], [u'Article 1', u'', None]]
It seems that Query.results_iter is getting the list of fields to pass to resolve_columns from self.model._meta.fields. For basic queries, this is fine, but it's wrong for values and values_list queries, and it's incomplete for select_related queries (this last appears to be a bug in trunk as well).
To fix this, I think that the Query object needs to maintain a list of field objects inside or alongside the Query.select and Query.related_select_cols lists.
Change History (6)
comment:2 follow-up: 4 Changed 9 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|