I have defined a self refential class ContentObject to build a node
tree wih parent child relationships.
class ContentObject(Base):
__tablename__ = 'contentobject'
_contentType = 'contentobject'
id = Column(types.Integer, primary_key=True, autoincrement=True)
parent_id = Column(types.Integer, ForeignKey('contentobject.id'))
type = Column(types.String(32))
children = relation("ContentObject", backref=backref('parent',
remote_side=id))
__mapper_args__ = {'polymorphic_on':type,
'polymorphic_identity':'contentobject'}
...
Everthing works fine until I define an additional foreign key
relation between 2 descandant classes of ContentObject.
class A(ContentObject):
__tablename__ = 'a'
__mapper_args__ = {'polymorphic_identity' : 'a'}
id = Column(types.Integer, ForeignKey(ContentObject.id),
primary_key=True)
datum = Column(types.Date)
class B(ContentObject):
__tablename__ = 'b'
__mapper_args__ = {'polymorphic_identity' : 'b}
id = Column(types.Integer, ForeignKey(ContentObject.id),
primary_key=True)
linkb_id = Column(types.Integer, ForeignKey(A.id))
linkb = relation(EloLijst, primaryjoin='b.c.a_id==a.c.id')
Now I get the error Can't determine between 'contentobject' and 'b':
tables have more than one foreign key constraint between them. Specify
onclause of this join explicitely
How should I do that?
--
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.