summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/unitofwork.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-10-27 09:51:50 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-10-27 09:51:50 -0400
commite56a9d85acd165cfea08f9dc7e9d747054ce6fdb (patch)
tree9b4945ac54be816787e58f9fe8745ef56e0a7690 /lib/sqlalchemy/orm/unitofwork.py
parent1f32d014da5d40406cd5d3996be5283c2fc57b26 (diff)
downloadsqlalchemy-e56a9d85acd165cfea08f9dc7e9d747054ce6fdb.tar.gz
Restore object to the identity_map upon delete() unconditionally
Fixed regression caused by :ticket:`2677` whereby calling :meth:`.Session.delete` on an object that was already flushed as deleted in that session would fail to set up the object in the identity map (or reject the object), causing flush errors as the object were in a state not accommodated by the unit of work. The pre-1.1 behavior in this case has been restored, which is that the object is put back into the identity map so that the DELETE statement will be attempted again, which emits a warning that the number of expected rows was not matched (unless the row were restored outside of the session). Change-Id: I9a8871f82cb1ebe67a7ad54d888d5ee835a9a40a Fixes: #3839
Diffstat (limited to 'lib/sqlalchemy/orm/unitofwork.py')
-rw-r--r--lib/sqlalchemy/orm/unitofwork.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py
index f3e39d9b5..de4842d6f 100644
--- a/lib/sqlalchemy/orm/unitofwork.py
+++ b/lib/sqlalchemy/orm/unitofwork.py
@@ -242,6 +242,9 @@ class UOWTransaction(object):
listonly=False, cancel_delete=False,
operation=None, prop=None):
if not self.session._contains_state(state):
+ # this condition is normal when objects are registered
+ # as part of a relationship cascade operation. it should
+ # not occur for the top-level register from Session.flush().
if not state.deleted and operation is not None:
util.warn("Object of type %s not in session, %s operation "
"along '%s' will not proceed" %