Hi, I'm running into a problem with my nested sets implementation. Inserting, moving, or removing a node can potentially affect one or more of many other nodes' tree properties (tree id, left, right, depth, or parent relationship). For efficiency's sake this change occurs as a single, rather complex SQL expression query that handles the magic of updating all the other node values.
Just as a precaution I've added a session.expire_all() after the session.execute(<query>), so that the tree values will be reloaded as I move on to process other node operations in the same transaction. However what I've discovered is that expire_all() causes *all* as-of- yet unpersisted changes to be lost. As an example of what I mean, here's an actual shell log: >>> obj = session.query(...) >>> obj.name u'root1' >>> obj.name = 'root66' >>> session.add(obj) >>> session.expire_all() >>> session.commit() >>> obj.name u'root1' It may be possible that I can restructure the order in which I do things so that stale data isn't an issue. But out of curiosity, is there a way to expire only *unchanged* stale data? This is how I naïvely expected expire_all() to work. Alternatively, a good API for this case would have been an expire_all(mapped_class, ['attribute', 'names']), a sort of compromise between expire() and expire_all(). -- 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.
