From 233756a018dd54aa611ec8147bfda09a3c16268e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 5 Apr 2010 14:53:19 -0400 Subject: [PATCH] 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. --- lib/sqlalchemy/orm/unitofwork.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) -- 2.47.3