]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
more complete commit when object list is specified
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 20 Dec 2005 05:26:13 +0000 (05:26 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 20 Dec 2005 05:26:13 +0000 (05:26 +0000)
lib/sqlalchemy/mapping/objectstore.py

index b86f7a325ac29e4e87d3dc32d4a432f8eb0d8328..0f633eb0c58d6211a367f5a8805d4c2ca7b5e438 100644 (file)
@@ -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: