]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
these are some assertions that would make things easier, if they can be maintained.
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Apr 2010 18:53:19 +0000 (14:53 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Apr 2010 18:53:19 +0000 (14:53 -0400)
otherwise, if listonly can go from True to False, then there's the whole cascades issue
to deal with, same for delete moving from False to True and vice versa.

lib/sqlalchemy/orm/unitofwork.py

index 83703ba11b9d207717111de6ca63fa64195ebf4c..0c3f595625f15005c7054c6bcf51095413949565 100644 (file)
@@ -147,10 +147,10 @@ class UOWTransaction(object):
             self.states[state] = (isdelete, listonly)
         elif isdelete or listonly:
             existing_isdelete, existing_listonly = self.states[state]
-            self.states[state] = (
-                                        existing_isdelete or isdelete, 
-                                        existing_listonly and listonly
-                                )
+            if not listonly and existing_listonly:
+                raise Exception("Can't upgrade from listonly to save")
+            if existing_isdelete != isdelete:
+                raise Exception("Can't change delete flag")
     
     def states_for_mapper(self, mapper, isdelete, listonly):
         checktup = (isdelete, listonly)