Hi,
I have a problem with relationships between objects which inherit the
same parent:
class Person(DeclarativeBase):
__tablename__ = 'person'
id = Column(Integer, primary_key=True)
name = Column(Unicode(100), nullable=False
def __init__(self, name):
self.name = name
class Employee(Person):
__tablename__ = 'employee'
id = Column(Integer, ForeignKey('person.id'), primary_key=True)
def __init__(self, name):
Person.__init__(self, name)
class Customer(Person):
__tablename__ = 'customer'
id = Column(Integer, ForeignKey('person.id'), primary_key=True)
employee_id = Column(Integer, ForeignKey('employee.id'))
employee = relationship("Employee", backref="employees"
def __init__(self, name, employee):
Person.__init__(self, name)
self.employee = employee
The error:
One or more mappers failed to initialize - can't proceed with
initialization of other mappers. Original exception was: Could not
determine join condition between parent/child tables on relationship
Customer.employee. Specify a 'primaryjoin' expression. If 'secondary'
is present, 'secondaryjoin' is needed as well.
Without generalisation there is no problem.
Thanks in advance!
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.