SQLAlchemy: When to use passive_deletes=”all” (with DELETE CASCADE in [e.g.] PostgreSQL)
SQLAlchemy provides a few options for handling “cascaded” deletions – from what I can gather, either the ORM tries to handle cascading itself (i.e., where passive_deletes=False
[default] and cascade="{...}, delete"
is set in a relationship()
definition), or it may be “informed” of a database-side ON DELETE CASCADE
configuration by specifying passive_deletes=True
, in which the ORM may defer some deletes to the DB.