我有一个类Revision
,Revision
具有以下定义:
class Revision(db.Model):
id = db.Column(db.Unicode, primary_key=True)
text = db.Column(db.Unicode)
此外,每个人都Revision
可以有一个祖先,就像与另一个人的关系一样Revision
。每个Revision
人还应该跟踪任何后继者,即以Revision
它为祖先的s。我尝试了以下两种方法:
ancestorId = db.Column(db.Unicode, db.ForeignKey("revision.id"))
successors = db.relationship("Revision", backref="ancestor", lazy="dynamic")
抛出:
sqlalchemy.exc.ArgumentError: Revision.successors and back-reference Revision.ancestor are both of the same direction <symbol 'ONETOMANY>. Did you mean to set remote_side on the many-to-one side ?
和
successors = db.relationship("Revision", backref="ancestor", lazy="dynamic")
抛出:
sqlalchemy.exc.ArgumentError: Could not determine join condition between parent/child tables on relationship Revision.successors. Specify a 'primaryjoin' expression. If 'secondary' is present, 'secondaryjoin' is needed as well.