summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiogo Dutra <dutradda@gmail.com>2016-09-29 19:59:34 -0300
committerGitHub <noreply@github.com>2016-09-29 19:59:34 -0300
commit4793a1a029b31f7943b860b60aec85127e944aa3 (patch)
tree71aec20f69ea10627a12c4da5e88371a48fad1b4
parent800a18aff2927433163afec3b7a4671eabe1c2e3 (diff)
downloadsqlalchemy-pr/309.tar.gz
Fixed the persistent_to_deleted eventpr/309
Got a reference of the deleted instance before remove it from state. The old code always send a None instead the instance.
-rw-r--r--lib/sqlalchemy/orm/session.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index 4a65e0719..7da30f9c2 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -1643,13 +1643,14 @@ class Session(_SessionClassMethods):
self.transaction._deleted[state] = True
self.identity_map.safe_discard(state)
+ obj = state.obj()
self._deleted.pop(state, None)
state._deleted = True
# can't call state._detach() here, because this state
# is still in the transaction snapshot and needs to be
# tracked as part of that
if persistent_to_deleted is not None:
- persistent_to_deleted(self, state.obj())
+ persistent_to_deleted(self, obj)
def add(self, instance, _warn=True):
"""Place an object in the ``Session``.