[Sqlalchemy-tickets] Issue #4004: one soft delete hook to rule them all (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Michael B. <iss...@bi...> - 2017-06-07 14:12:35
|
New issue 4004: one soft delete hook to rule them all https://bitbucket.org/zzzeek/sqlalchemy/issues/4004/one-soft-delete-hook-to-rule-them-all Michael Bayer: not really sure how this should look but goals are: 1. ORM keeps "delete" semantics completely. session.delete(obj), relationships will use cascade='all, delete, delete-orphan' normally, so that everything looks like "DELETE" 2. the critical part is unitofwork.register_object(). that's where the "thing" happens that determines the "deletedness" of all objects. unlike session.delete(), this is the place where it happens for all the relationship cascades also. 3. I am loathe to add a plain event inside of unitofwork.register_object(). at this point we are asking too much of users to understand internal flow. before_flush() is right at the top, fine. before_update() / before_delete(), right before the statement, OK. But because of relationship operations that take place in dependency.py, before_flush() doesn't tell us about everything that will happen in the flush and we can't react to everything. 4. the hook is really something that happens specific to UOW - after all the presorts are done and before the actions proceed. register_object() hook still seems like the way to go. this could also impact versioning recipes too. see if a register_object() hook can come up with recipes that handle both soft_delete and versioning. that could help come up with some way to explain it. |