更新时间:2023-01-14 23:20:08
您应该只需要:
prev_lines = relationship(
Association,
backref="next_lines",
primaryjoin=id==Association.prev_id)
由于它指定了next_lines
后向引用,因此无需具有next_lines
关系.
Since this specifies the next_lines
back reference there is no need to have a next_lines
relationship.
You can also do this using the remote_side
parameter to a relationship: http://www.sqlalchemy.org/trac/browser/examples/adjacency_list/adjacency_list.py