美文网首页
2018-06-07 delete列时,关联表的删除

2018-06-07 delete列时,关联表的删除

作者: lucasdada | 来源:发表于2018-06-07 11:44 被阅读0次
session.delete(jack)
session.query(User).filter_by(name='jack').count()
>>> session.query(Address).filter(
...     Address.email_address.in_(['jack@google.com', 'j25@yahoo.com'])
...  ).count()
2

Uh oh, they’re still there ! Analyzing the flush(缓冲) SQL, we can see that the user_id column of each address was set to NULL, but the rows weren’t deleted. SQLAlchemy doesn’t assume(承担) that deletes cascade(层叠), you have to tell it to do so.

相关文章

网友评论

      本文标题:2018-06-07 delete列时,关联表的删除

      本文链接:https://www.haomeiwen.com/subject/jstgsftx.html