On 4/25/2010 6:39 AM, Adrian wrote:
class MenuNode(Base): __tablename__ = 'menu' id = Column(Integer, primary_key=True, nullable=False, unique=True) parent_id = Column(Integer, ForeignKey('menu.id', onupdate='CASCADE', ondelete='CASCADE'), nullable=True, index=True) name = Column(String(64), nullable=False)parent = relationship('MenuNode', remote_side='MenuNode.id', cascade='all, delete', passive_deletes=True, backref=backref('children', order_by=position)) Top-level menu nodes have parent_id=NULL. When deleting a node via session.delete(node) sqlalchemy issues UPDATE statements to set all children's parent_id fields to NULL instead of deleting the children. How can i tell SA that I want to delete any children?
Does specifying cascade='all, delete-orphan' on the parent relationship accomplish what you're after? Lance -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
