From ad8ad86470a61acecb361f673dbb74b36dedd3a7 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 3 Apr 2010 18:08:48 -0400 Subject: [PATCH] tweak how we indicate child deleted here --- lib/sqlalchemy/orm/dependency.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index ff7148871a..86cac2d875 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -92,7 +92,7 @@ class DependencyProcessor(object): # its not, so we will link per-state # actions to the aggregate "saves", "deletes" actions child_actions = [ - child_saves, child_deletes + (child_saves, False), (child_deletes, True) ] else: # it is. see if there's any objects. @@ -104,13 +104,13 @@ class DependencyProcessor(object): if child_state is None: continue if child_state not in uow.states: - child_action = None + child_action = (None, None) else: (deleted, listonly) = uow.states[child_state] if deleted: - child_action = unitofwork.DeleteState(uow, child_state) + child_action = (unitofwork.DeleteState(uow, child_state), True) else: - child_action = unitofwork.SaveUpdateState(uow, child_state) + child_action = (unitofwork.SaveUpdateState(uow, child_state), False) child_actions.append(child_action) # check if the "parent" side is part of the cycle, @@ -135,11 +135,12 @@ class DependencyProcessor(object): # establish dependencies between our possibly per-state # parent action and our possibly per-state child action. - for child_action in child_actions: + for (child_action, childisdelete) in child_actions: self.per_state_dependencies(uow, parent_saves, parent_deletes, child_action, - after_save, before_delete, isdelete) + after_save, before_delete, + isdelete, childisdelete) def presort_deletes(self, uowcommit, states): pass @@ -260,7 +261,8 @@ class OneToManyDP(DependencyProcessor): save_parent, delete_parent, child_action, - after_save, before_delete, isdelete): + after_save, before_delete, + isdelete, childisdelete): if not isdelete: uow.dependencies.update([ (save_parent, after_save), @@ -401,14 +403,15 @@ class ManyToOneDP(DependencyProcessor): save_parent, delete_parent, child_action, - after_save, before_delete, isdelete): + after_save, before_delete, + isdelete, childisdelete): if not isdelete: uow.dependencies.update([ (child_action, after_save), (after_save, save_parent), ]) else: - if isinstance(child_action, unitofwork.DeleteState): + if childisdelete: uow.dependencies.update([ (delete_parent, child_action) ]) -- 2.47.3