Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#14243 closed (invalid)

defer and only are not respected by values and by valuest_list()

Reported by: pma_ Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords: defer only values
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

data model with 2 field owner and category

run query like
result = CatalogCategories.objects.only('id', 'category').values() #or values_list()

you always will get full record

Change History (2)

comment:1 Changed 6 years ago by Austin Gabel

Resolution: invalid
Status: newclosed

This usage is incorrect. To limit the fields returned by values() they must be added as arguments. (ex. CatalogCategories.objects.values('id', 'category') ) Since you have not specified any fields, they will all be returned.
Documentation can be found at http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields
I'm changing this ticket to invalid.

comment:2 Changed 6 years ago by Luke Plant

Just to clarify what agabel said: defer and only are about which attributes of an model instance are lazily loaded. values returns something entirely different, so it wouldn't make sense for it to be affected.

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