diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-06-18 13:31:51 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-06-18 13:31:51 -0400 |
commit | 41cf0a7ac8754fcb6943dee633aeed9d56e460d3 (patch) | |
tree | 486ebd894fae12a56b036100016273f0822875ae /lib/sqlalchemy/orm/unitofwork.py | |
parent | 1baca8908450ee56c87068fc5d87840208aac146 (diff) | |
download | sqlalchemy-41cf0a7ac8754fcb6943dee633aeed9d56e460d3.tar.gz |
this one is actually doing it. removed the cruft we don't need from the old approach.
not sure if one-to-many with elaborate self-refs, etc., but we appear to be
as good as we were before.
Diffstat (limited to 'lib/sqlalchemy/orm/unitofwork.py')
-rw-r--r-- | lib/sqlalchemy/orm/unitofwork.py | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index aed50f649..529a94d5d 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -110,7 +110,7 @@ class UOWTransaction(object): # or insert/updated, or just refreshed self.states = {} - self.post_update_states = util.defaultdict(set) + self.post_update_states = util.defaultdict(lambda: (set(), set())) @property def has_work(self): @@ -185,14 +185,11 @@ class UOWTransaction(object): if not listonly and (isdelete or cancel_delete): self.states[state] = (isdelete, False) - def issue_post_update(self, state, post_update_cols, immediate): - if immediate: - mapper = state.manager.mapper.base_mapper - mapper._save_obj([state], self, \ - postupdate=True, \ - post_update_cols=set(post_update_cols)) - else: - self.post_update_states[state].update(post_update_cols) + def issue_post_update(self, state, post_update_cols): + mapper = state.manager.mapper.base_mapper + states, cols = self.post_update_states[mapper] + states.add(state) + cols.update(post_update_cols) @util.memoized_property def _mapper_for_dep(self): @@ -426,18 +423,12 @@ class PostUpdateThing(PostSortRec): self.isdelete = isdelete def execute(self, uow): - states = [] - update_cols = set() - - for state in uow.states_for_mapper_hierarchy(self.mapper, self.isdelete, False): - if state not in uow.post_update_states: - continue - states.append(state) - update_cols.update(uow.post_update_states[state]) - + states, cols = uow.post_update_states[self.mapper] + states = [s for s in states if uow.states[s][0] == self.isdelete] + self.mapper._save_obj(states, uow, \ postupdate=True, \ - post_update_cols=update_cols) + post_update_cols=cols) class SaveUpdateAll(PostSortRec): def __init__(self, uow, mapper): |