summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/unitofwork.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-04-24 18:06:27 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-04-24 18:06:27 -0400
commit9cf10db8aa4692dc615f1a03db5ffe342c321586 (patch)
treebc175ec68845968fd307317c062db44319d1688b /lib/sqlalchemy/orm/unitofwork.py
parentcfe56e3735d2ba34923c36e9f015253e535ed1bd (diff)
downloadsqlalchemy-9cf10db8aa4692dc615f1a03db5ffe342c321586.tar.gz
- [feature] Calling rollback() within a
session.begin_nested() will now only expire those objects that had net changes within the scope of that transaction, that is objects which were dirty or were modified on a flush. This allows the typical use case for begin_nested(), that of altering a small subset of objects, to leave in place the data from the larger enclosing set of objects that weren't modified in that sub-transaction. [ticket:2452] - inline the "register_newly_XYZ" functions to operate upon collections to reduce method calls
Diffstat (limited to 'lib/sqlalchemy/orm/unitofwork.py')
-rw-r--r--lib/sqlalchemy/orm/unitofwork.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py
index 3523e7d06..bc3be8b41 100644
--- a/lib/sqlalchemy/orm/unitofwork.py
+++ b/lib/sqlalchemy/orm/unitofwork.py
@@ -339,13 +339,14 @@ class UOWTransaction(object):
execute() method has succeeded and the transaction has been committed.
"""
- for state, (isdelete, listonly) in self.states.iteritems():
- if isdelete:
- self.session._remove_newly_deleted(state)
- else:
- # if listonly:
- # debug... would like to see how many do this
- self.session._register_newly_persistent(state)
+ states = set(self.states)
+ isdel = set(
+ s for (s, (isdelete, listonly)) in self.states.iteritems()
+ if isdelete
+ )
+ other = states.difference(isdel)
+ self.session._remove_newly_deleted(isdel)
+ self.session._register_newly_persistent(other)
class IterateMappersMixin(object):
def _mappers(self, uow):