#11263: Bug in lookup with generic relation in model inheritance
---------------------------------------------------+------------------------
          Reporter:  veena                         |         Owner:  nobody     
                         
            Status:  new                           |     Milestone:  1.3        
                         
         Component:  Database layer (models, ORM)  |       Version:  SVN        
                         
        Resolution:                                |      Keywords:  generic 
relations, model inheritance
             Stage:  Accepted                      |     Has_patch:  1          
                         
        Needs_docs:  1                             |   Needs_tests:  1          
                         
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by nator):

 Caveat: I'm new to Django and Python.

 That said, I did some poking around in django/db/models/sql/query.py and
 found a tweak that "fixes" this.  In the setup_joins function there's a
 block of code that looks like this (it's within the test block for direct,
 and then within the test for m2m):
 {{{
                     if int_alias == table2 and from_col2 == to_col2:
                         joins.append(int_alias)
                         alias = int_alias
                     else:
                         alias = self.join(
                                 (int_alias, table2, from_col2, to_col2),
                                 dupe_multis, exclusions, nullable=True,
                                 reuse=can_reuse)
                         joins.extend([int_alias, alias])
 }}}

 The problem with the bad SQL being generated is a redundant and wrong
 inner_join.  If I change that first test to:
 {{{
                     if int_alias == table2 and from_col2 == from_col1:
 }}}
 it works.  (basically changing the test to check for this redundant
 situation)

 I don't really recommend this as a patch since I don't fully understand
 the ramifications of the change - what else am I breaking by doing this?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11263#comment:15>
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