2
使用SQLAlchemy 1.0.13,是否可以从继承类中删除relationship join?使用继承删除SQLAlchemy关系
在下一个最小的工作示例中,我有一个父母和两种孩子。子类与父类有关系。 AlienChild从Child获取所有属性,但我想放弃关系。这可能吗?
class Parent(Base):
__tablename__ = 'parent'
id = Column(Integer, primary_key=True)
class Child(Base):
__tablename__ = 'child'
id = Column(Integer, primary_key=True)
parent_id = Column(Integer,
ForeignKey('parent.id',
ondelete='CASCADE'),
nullable=False)
parent = relationship('Parent',
backref=backref(
'children', cascade="all, delete-orphan"),
foreign_keys=[parent_id],
single_parent=True)
class AlienChild(Child):
__tablename__ = 'alienchild'
parent = droprelationship('Parent')