I have a many-to-many relationship between User
s and Task
s. I want the \"secondary table\" (meaning, the table that facilitates the many-to-many relat
See delete(synchronize_session='evaluate'):
The method does not offer in-Python cascading of relationships - it is assumed that ON DELETE CASCADE is configured for any foreign key references which require it. The Session needs to be expired (occurs automatically after commit(), or call expire_all()) in order for the state of dependent objects subject to delete or delete-orphan cascade to be correctly represented.
That is, SQLAlchemy isn't able to find all the Task objects you're deleting and figure out each row to be deleted from user_tasks - the best way to do this is to use ON DELETE CASCADE on the foreign keys (won't work with MySQL MyISAM tables or SQLite if foreign keys aren't enabled):
http://docs.sqlalchemy.org/en/latest/core/constraints.html#on-update-and-on-delete