On Tue, Jul 21, 2009 at 10:47 AM, Michael Bayer<mike...@zzzcomputing.com> wrote: > > Jon Nelson wrote: >> >> I encountered an odd issue today that I can't explain, and it seems like a >> bug. >> I've checked 0.5.4p2 and 0.5.5, and the behavior is the same. > > its a mistake I've seen before. Backrefs change the collection, so the > iteration ends up granting only every other item. > > # solution > for child in list(root.children): > child.parent = new_root
Aha! Could some note be added to the docs? CAVEAT: operations which change collections should not be used in loops. I'm well aware of the same situation with dicts and lists and so on but for some reason completely missed it here. > also the root.parent = root thing will require post_update, see the mapper > docs for this. Sweet. Thanks! -- Jon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---