#7270: selected_related() can not follow reverse relations of OneToOne.
---------------------------------------------------+------------------------
          Reporter:  towjz...@hotmail.com          |         Owner:  
mtredinnick                    
            Status:  new                           |     Milestone:  1.2        
                    
         Component:  Database layer (models, ORM)  |       Version:  SVN        
                    
        Resolution:                                |      Keywords:  
select_related onetoone reverse
             Stage:  Accepted                      |     Has_patch:  1          
                    
        Needs_docs:  0                             |   Needs_tests:  1          
                    
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by bendavis78):

  * needs_better_patch:  1 => 0
  * needs_tests:  0 => 1

Comment:

 Ok,  I've updated the patch and fixed some code that was mysteriously
 duplicated,  as well as fixed the tests that were written for the
 select_related change (they just needed __init__ files).

 I also believe I have the .values() query working with reverse one-to-one
 relationships,  though I'd really like mtredinnick to take a look at the
 change since he's the one that wrote the original code for this.  The
 change was fairly simple.  In the setup_joins function in
 db/models/sql/query.py:
 {{{
                      raise FieldError("Cannot resolve keyword %r into
 field. "
                              "Choices are: %s" % (name, ", ".join(names)))

 -            if not allow_many and (m2m or not direct):
 +            if not allow_many and m2m:
                  for alias in joins:
                      self.unref_alias(alias)
                  raise MultiJoin(pos + 1)
 }}}

 Looking at the original code,  I'm not sure why "indirect" fields were not
 allowed if they weren't many-to-many relationships.  This is basically
 what was keeping the reverse one-to-one lookups from working.  I'm not
 100% sure of the consequences of this change,  but all model tests seemed
 to pass with this change.

 @mtredinnick:  thoughts?

 We still need a test for this particular change, so I'm leaving "Needs
 tests" checked for now.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7270#comment:41>
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-updates@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