Hi all, I'm trying to load a whole Tree of Account objects (Mapped instances) in a single SELECT with unlimited depth. I'm using PostgreSQL connectby function from the tablefunc module. It returns rows of each nodes in a depth first visit.
sql = """ SELECT acc_accounts.* FROM connectby('acc_accounts', 'account_id', 'parent_id', 'name', '%s', 0) AS t(keyid int, parent_keyid int, level int, name int), acc_accounts where keyid = account_id """ accounts = Session.query(Account).from_statement(sql % root_account_id).all() After that, I try so iterate over the result list in order to set the account.children relation myself. But the problem is that as soon as I initialize the relation, a SQL select is issued: account.children = [] How can I avoid these unnecessary selects on all nodes? Is there a better way to let SA populate the relation with the rows returned? Thanks for help. jean-philippe --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---