So, if I understand you correctly this is more some kind of bug in sqlalchemy than a problem with my code, am I right?
Regards, Christopher. On Jul 26, 8:11 pm, Michael Bayer <[email protected]> wrote: > unit of work logging can be enabled: > > import logging > logging.basicConfig() > logging.getLogger('sqlalchemy.orm.unitofwork').setLevel(logging.DEBUG) > > when a class has a relation to itself, a dependency is created during > flush: > > DEBUG:sqlalchemy.orm.unitofwork.UOWTransaction:Dependent tuples: > (Forum->Forum) > > it means, we can no longer insert all Forum rows in the order they > were received - we have to check each object for dependencies on a > parent Forum object and modify the insert order in that way. > > A sort is then performed among all three Forum objects, where "sort" > is a topological dependency sort. The ordering of this sort is not > deterministic. in this case, there are no dependencies at all so the > sort turns up an ordering that is mostly random. but topological > doesn't take "insert order" into account at this level. > > the resulting list is then grouped into a tree-like structure, which > is intended to create "batches" of objects, where within each batch, > the uow can again fall back upon the insert ordering among those > rows. the "tree" step is total craziness which I wrote at some point > and was rewritten by ants aasma, our resident uber genius, and would > be great to get rid of. > > Here's what the code has to say: > > # rationale for "tree" sort as opposed to a straight > # dependency - keep non-dependent objects > # grouped together, so that insert ordering as determined > # by session.add() is maintained. > # An alternative might be to represent the "insert order" > # as part of the topological sort itself, which would > # eliminate the need for this step (but may make the original > # topological sort more expensive) > > so in theory topological could be improved to take "insert order" into > account, we can lose the unnecessary tree stage which doesn't really > solve the issue completely anyway, and that would probably improve > this test. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
