#13442: only() and defer() will always select id
--------------------------------------+-------------------------------------
          Reporter:  mampf            |         Owner:     
            Status:  closed           |     Milestone:     
         Component:  ORM aggregation  |       Version:  1.1
        Resolution:  invalid          |      Keywords:     
             Stage:  Unreviewed       |     Has_patch:  0  
        Needs_docs:  0                |   Needs_tests:  0  
Needs_better_patch:  0                |  
--------------------------------------+-------------------------------------
Changes (by lukeplant):

  * status:  new => closed
  * needs_better_patch:  => 0
  * resolution:  => invalid
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 The docs state that the primary key can never be deferred.  We have to
 include the primary key, because the other fields in the return objects
 need to be lazily loaded.  For that to work, we need to store the id so
 that we can later retrieve the right row of the database if needed.

 Your use case doesn't really fit the reasons why either `distinct()` or
 `only()` exist.  `only()` is about only retrieving certain fields of
 '''objects''', not generating arbitrary SQL.  You may need to use some raw
 SQL to get what you want.

 Thanks.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13442#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to