这是我的设置:
class User(Base):
__tablename__ = 'users'
user_id = Column(Integer, primary_key=True)
class Object(Base):
__tablename__ = 'objects'
object_id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey('User.user_id'))
class ObjectHistory(Base):
__tablename__ = 'object_histories'
history_id = Column(Integer, primary_key=True)
object_id = Column(Integer, primary_key=True)
class Action(Base):
__tablename__ = 'actions'
action_id = Column(Integer, primary_key=True)
class ActionDetail(Base):
__tablename__ = 'action_details'
detail_id = Column(Integer, primary_key=True)
history_id = Column(Integer, ForeignKey('ObjectHistory.id')
object = relationship('Object', secondary='object_histories',
primaryjoin='ActionDetail.history_id==ObjectHistory.history_id',
secondaryjoin='Object.object_id==ObjectHistory.object_id',
backref='action_details')
user = relationship('User', ????, backref='action_details')
如何在ActionDetail上创建user
关系?可能吗?我尝试过类似上面object
关系的东西,但无济于事。