Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#10256 closed (fixed)

values() and values_list() either include all or no columns from the extra(select=) clause

Reported by: russellm Owned by: russellm
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

By way of example, this is what 1.0.X produces:

>>> Book.objects.extra(select={'a':'name','b':'price','c':'pages'}).values('name','pages','a')
[{'a': u'Book 1', 'c': 11, 'b': Decimal("11.11"), 'name': u'Book 1', 'pages': 11}, ...

>>> Book.objects.extra(select={'a':'name','b':'price','c':'pages'}).values('name','pages')
[{'name': u'Book 1', 'pages': 11}, ...

That is, if you don't explicitly mention an extra selected column in the values() clause, they are omitted (as expected). However, as soon as you include a single extra column, _all_ extra columns are included in the returned values.

Analogous behavior exists for values_list().

Change History (3)

comment:1 Changed 7 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to russellm
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I'm working on this - I should commit a fix shortly.

comment:2 Changed 7 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [9837]) Fixed #10256 -- Corrected the interaction of extra(select=) with values() and values_list() where an explicit list of columns is requested.

comment:3 Changed 7 years ago by russellm

(In [9884]) [1.0.X] Fixed #10256 -- Corrected the interaction of extra(select=) with values() and values_list() where an explicit list of columns is requested.

Merge of r9837 from trunk.

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