Thank you for the suggestion but the extension method doesn't fired, even without raw sql:
mapper(Account, table_accounts, extension=AccountLoader(), properties=dict( children = relation(Account, lazy=None, primaryjoin=table_accounts.c.parent_id==table_accounts.c.account_id, #cascade="all", collection_class=attribute_mapped_collection('name'), backref=backref('parent', primaryjoin=table_accounts.c.parent_id==table_accounts.c.account_id, remote_side=table_accounts.c.account_id) ), chart = relation(Account, lazy=None, uselist=False, post_update=True, primaryjoin=table_accounts.c.chart_id==table_accounts.c.account_id, remote_side=table_accounts.c.account_id, backref=backref('descendants', lazy=None, join_depth=1, primaryjoin=table_accounts.c.chart_id==table_accounts.c.account_id, viewonly=True) ), class AccountLoader(MapperExtension): def append_result(self, mapper, selectcontext, row, instance, result, **flags): isnew = flags.get('isnew', False) if instance.parent_id is None: result.append(instance) else: if isnew or selectcontext.populate_existing: key = mapper.identity_key_from_primary_key(instance.parent_id) parentnode = selectcontext.session.identity_map[key] parentnode.children.append(instance) return False accounts = Session.query(Account).filter(Account.c.chart_id==1).all() How can I fire the extension callback without eager loading descendants? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---