I'm using the "joined table inheritance" model. I have three levels of inheritance.
class has_polymorphic_id(object):
@declared_attr.cascading
def record_id(cls):
if has_inherited_table(cls):
return Column(ForeignKey('employee.record_id'),
primary_key=True)
else:
return Column(Integer, primary_key=True)
class Employee(has_polymorphic_id, Base):
__tablename__ = 'employee'
name = Column(String(50))
type = Column(String(50))
__mapper_args__ = {
'polymorphic_identity':'employee',
'polymorphic_on':type
}
class Engineer(Employee):
__tablename__ = 'engineer'
....
class Programmer(Engineer):
__tablename__ = 'programmer'
....
This only works for the second level, namely `Enginner` can inherits the foreignkey/primarykey from `Employee`'s mixin, but the next level, the `Programmer`, python gives me an error:
`sqlalchemy.exc.NoForeignKeysError: Can't find any foreign key relationships between 'engineer' and 'programmer'.`
Is this designed this way? And if I manually set the foreignkey, should the third level reference to the base level or to its immediate parent level's primarykey?