#18174: Model inheritance pointers doesn't refer to parent to refer to 
grandparents
----------------------------------------------+--------------------
     Reporter:  phowe                         |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.4
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 I Create the Following Models:

 {{{
 class Base1( models.Model ):
   b1_id = models.AutoField( primary_key=True )
   b1_desc = models.CharField( max_length=100 )

 class Base2( models.Model ):
   b2_id = models.AutoField( primary_key=True )
   b2_desc = models.CharField( max_length=100 )

 class Base3( models.Model ):
   b3_id = models.AutoField( primary_key=True )
   b3_desc = models.CharField( max_length=100 )

 class Middle( Base1, Base2, Base3 ):
   m_desc = models.CharField( max_length=100 )

 class Top( Middle ):
   t_desc = models.CharField( max_length=100 )
 }}}

 I run this:
 {{{
 d = Top1.objects.all()
 print d.query
 }}}

 I get:
 {{{
 SELECT "Test_base1"."b1_id", "Test_base1"."b1_desc", "Test_base2"."b2_id",
 "Test_base2"."b2_desc", "Test_base3"."b3_id", "Test_base3"."b3_desc",
 "Test_middle"."base3_ptr_id", "Test_middle"."base2_ptr_id",
 "Test_middle"."base1_ptr_id", "Test_middle"."m_desc",
 "Test_top1"."middle_ptr_id", "Test_top1"."t1_desc"
   FROM "Test_top1"
   INNER JOIN "Test_base1" ON ("Test_top1"."middle_ptr_id" =
 "Test_base1"."b1_id")
   INNER JOIN "Test_base2" ON ("Test_top1"."middle_ptr_id" =
 "Test_base2"."b2_id")
   INNER JOIN "Test_base3" ON ("Test_top1"."middle_ptr_id" =
 "Test_base3"."b3_id")
   INNER JOIN "Test_middle" ON ("Test_top1"."middle_ptr_id" =
 "Test_middle"."base1_ptr_id")
 }}}

 It refers the top object directly to the base objects.  I would expect:

 {{{
   FROM "Test_top1"
   INNER JOIN "Test_middle" ON ("Test_top1"."middle_ptr_id" =
 "Test_middle"."base1_ptr_id")
   INNER JOIN "Test_base1" ON ("Test_middle"."base1_ptr_id" =
 "Test_base1"."b1_id")
   INNER JOIN "Test_base2" ON ("Test_middle"."base2_ptr_id" =
 "Test_base2"."b2_id")
   INNER JOIN "Test_base3" ON ("Test_middle"."base3_ptr_id" =
 "Test_base3"."b3_id")
 }}}

 This would normally not be a problem, however if I create a Top2 object or
 a Middle, now the ptr_ids will not all be incrementing at the same rate.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18174>
Django <https://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