From: Mike Bayer Date: Tue, 20 Dec 2005 05:26:13 +0000 (+0000) Subject: more complete commit when object list is specified X-Git-Tag: rel_0_1_0~224 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e512ec0fc00d6cb5cfe979dcda65ab026e117a5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git more complete commit when object list is specified --- diff --git a/lib/sqlalchemy/mapping/objectstore.py b/lib/sqlalchemy/mapping/objectstore.py index b86f7a325a..0f633eb0c5 100644 --- a/lib/sqlalchemy/mapping/objectstore.py +++ b/lib/sqlalchemy/mapping/objectstore.py @@ -223,27 +223,31 @@ class UnitOfWork(object): commit_context = UOWTransaction(self) if len(objects): - for obj in objects: - if self.deleted.contains(obj): - commit_context.register_object(obj, isdelete=True) - elif self.new.contains(obj) or self.dirty.contains(obj): - commit_context.register_object(obj) + objset = util.HashSet(iter=objects) else: - for obj in [n for n in self.new] + [d for d in self.dirty]: - if self.deleted.contains(obj): + objset = None + + for obj in [n for n in self.new] + [d for d in self.dirty]: + if objset is not None and not objset.contains(obj): + continue + if self.deleted.contains(obj): + continue + commit_context.register_object(obj) + for item in self.modified_lists: + obj = item.obj + if objset is not None and not objset.contains(obj): + continue + if self.deleted.contains(obj): + continue + commit_context.register_object(obj, listonly = True) + for o in item.added_items() + item.deleted_items(): + if self.deleted.contains(o): continue - commit_context.register_object(obj) - for item in self.modified_lists: - obj = item.obj - if self.deleted.contains(obj): - continue - commit_context.register_object(obj, listonly = True) - for o in item.added_items() + item.deleted_items(): - if self.deleted.contains(o): - continue - commit_context.register_object(o, listonly=True) - for obj in self.deleted: - commit_context.register_object(obj, isdelete=True) + commit_context.register_object(o, listonly=True) + for obj in self.deleted: + if objset is not None and not objset.contains(obj): + continue + commit_context.register_object(obj, isdelete=True) engines = util.HashSet() for mapper in commit_context.mappers: