Hi there, I'm trying to figure out whether there's something in SQLAlchemy that lets me reliably get all the objects related to another: i.e. all children of a parent that (in the underlying record) have a foreign key relationship to the parent record.
One way I've been trying to solve this is by inspecting the underlying tables directly, inspecting the foreign_keys property of the tables. But this is mixing levels however - I get into trouble getting from ORMed object to record and back again (having to expunge the session, etc). I was wondering whether there is something in the ORM that can help me here. It tricks me that the cascading behavior might be close to what I'm looking for, but I'm not sure. I've tried to use the cascade_iterator on the mapper but I'm not sure I'm using it right (as I get no related objects while I expect some, or an error). If there is a way to get the related objects (in the session or not; I need all of them) in the ORM layer, could someone post me a snippet? I've been trying something like: foo = <some orm mapped object> m = object_mapper(foo) related = list(m.cascade_iterator('all', foo)) I'm not sure whether I'm passing the right arguments or whether the cascade story is even suitable for that. I just get an empty list, even though foo does have several objects that refer to it. Any ideas? Regards, Martijn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---