diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2016-10-27 10:46:15 -0400 |
|---|---|---|
| committer | Gerrit Code Review <gerrit2@ln3.zzzcomputing.com> | 2016-10-27 10:46:15 -0400 |
| commit | 3f1fe4e33c3231ae791b0ffcc541305f90019ce7 (patch) | |
| tree | df5ce71d1173ffcf50f0b2df40e5a8c2e355796f /lib/sqlalchemy | |
| parent | 9974ab67f508a16423e8bc22122180b0bcdee807 (diff) | |
| parent | e56a9d85acd165cfea08f9dc7e9d747054ce6fdb (diff) | |
| download | sqlalchemy-3f1fe4e33c3231ae791b0ffcc541305f90019ce7.tar.gz | |
Merge "Restore object to the identity_map upon delete() unconditionally"
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/session.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/unitofwork.py | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index b492cbb7f..b39ba1465 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -1726,8 +1726,9 @@ class Session(_SessionClassMethods): if state in self._deleted: return + self.identity_map.add(state) + if to_attach: - self.identity_map.add(state) self._after_attach(state, obj) if head: @@ -2196,7 +2197,8 @@ class Session(_SessionClassMethods): for state in proc: is_orphan = ( _state_mapper(state)._is_orphan(state) and state.has_identity) - flush_context.register_object(state, isdelete=is_orphan) + _reg = flush_context.register_object(state, isdelete=is_orphan) + assert _reg, "Failed to add object to the flush context!" processed.add(state) # put all remaining deletes into the flush context. @@ -2205,7 +2207,8 @@ class Session(_SessionClassMethods): else: proc = deleted.difference(processed) for state in proc: - flush_context.register_object(state, isdelete=True) + _reg = flush_context.register_object(state, isdelete=True) + assert _reg, "Failed to add object to the flush context!" if not flush_context.has_work: return 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" % |
