From: Mike Bayer Date: Mon, 5 Apr 2010 18:53:19 +0000 (-0400) Subject: these are some assertions that would make things easier, if they can be maintained. X-Git-Tag: rel_0_6_0~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=233756a018dd54aa611ec8147bfda09a3c16268e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git these are some assertions that would make things easier, if they can be maintained. 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. --- diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index 83703ba11b..0c3f595625 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -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)