summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/unitofwork.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-04-05 17:24:00 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-04-05 17:24:00 -0400
commitf288339e95ff1624473ecaa70f977db4059dfe2b (patch)
tree8aa49183a2200ad77d6996c3db87dccbc613da23 /lib/sqlalchemy/orm/unitofwork.py
parente0e60a6c9490a4efa648cf33ada7387ce0f91dda (diff)
downloadsqlalchemy-f288339e95ff1624473ecaa70f977db4059dfe2b.tar.gz
looks like most of the issues are because we're losing insert ordering
on cycles. so lets reintroduce the organize as tree component, which works here. still need to make it meaningful by teaching the save/delete state actions to receive a set of items to match up
Diffstat (limited to 'lib/sqlalchemy/orm/unitofwork.py')
-rw-r--r--lib/sqlalchemy/orm/unitofwork.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py
index 432e2e238..9f888f867 100644
--- a/lib/sqlalchemy/orm/unitofwork.py
+++ b/lib/sqlalchemy/orm/unitofwork.py
@@ -219,8 +219,21 @@ class UOWTransaction(object):
print "------------------------"
print self.dependencies
print sort
- for rec in sort:
- rec.execute(self)
+
+ if cycles:
+ # organize into a tree so that groups of nodes can be
+ # merged together, allowing better maintenance of insert
+ # ordering and other things
+ (head, children) = topological.organize_as_tree(self.dependencies, sort)
+ stack = [(head, children)]
+
+ while stack:
+ node, children = stack.pop()
+ node.execute(self)
+ stack += children
+ else:
+ for rec in sort:
+ rec.execute(self)
def finalize_flush_changes(self):