Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 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

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by agabel

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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 4 years ago by lukeplant

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.