﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18174	Model inheritance pointers doesn't refer to parent to refer to grandparents	phowe	nobody	"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."	Bug	closed	Database layer (models, ORM)	1.4	Normal	fixed		Melvyn Sopacua	Accepted	1	0	0	1	0	0
