I aam having an issue defining a 2nd foreign key constraint on 2
derived classes of a base class that uses a self referential join.

Base class:ContentBase

class ContentBase(Base):
    __tablename__ = 'content'
    __mapper_args__ = {'polymorphic_on': ctype,
'polymorphic_identity':'contentbase'}
    id = Column(types.Integer, primary_key=True, autoincrement=True)
    children = relationship("ContentBase", backref=backref('parent',
remote_side=id))
    ....

Derived class CdRoot

class CdRoot(ContentBase):
    __tablename__ = 'cdroot'
    __mapper_args__ = {'polymorphic_identity' : 'cdroot'}
    contentType = 'CdRoot'
    id = Column(types.Integer, ForeignKey(ContentBase.id),
primary_key=True)
    clubs = relationship('CdClub', primaryjoin="cdroot.id ==
cdclub.cdroot_id")
    ...

Derived class CdClub

class CdClub(ContentBase):
    __tablename__ = 'cdclub'
    __mapper_args__ = {'polymorphic_identity' : 'cdclub'}
    id = Column(types.Integer, ForeignKey(ContentBase.id),
primary_key=True)
    cdroot_id = Column(types.Integer, ForeignKey(CdRoot.id))
    ...

The 2nd join between CdRoot and CdClub fails with the message : Can't
determine join between content and
cdclub, tables have more than one FK constraint.

Apparently the primaryjoin condition is not sufficient to get rid of
the error.  Any clue how to solve this

Ruben

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to