#14121: Provide object's primary key as a hint for database router method
db_for_read() when filtering objects by primary key
---------------------------------------------------+------------------------
          Reporter:  [email protected]              |         Owner:  nobody     
  
            Status:  new                           |     Milestone:             
  
         Component:  Database layer (models, ORM)  |       Version:  1.2        
  
        Resolution:                                |      Keywords:  router, 
hints
             Stage:  Unreviewed                    |     Has_patch:  0          
  
        Needs_docs:  0                             |   Needs_tests:  0          
  
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by russellm):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 In principle, I have no objection to passing in more hint data to the
 router, and your use case is certainly compelling. However, I'm not sure
 what you're describing here is possible (in the general case, anyway).

 User.objects.get(...) is literally a shortcut for
 User.objects.filter(...)[0]; so the arguments to get() can be any
 combination of filters that will result in the return of a single record.
 This could be the primary key, a non-primary key, a combination of fields
 that are unique together, or a field that isn't unique, but will only
 return a single result due to business logic. I've even seen get() used as
 a "check that there is exactly one record" check.

 So -- no problem with the idea in principle, but it needs more
 elaboration.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14121#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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to