To be more precise, the code: j = outerjoin( task_t, message_t, task_t.c.id==message_t.c.task_id) jj = select([ task_t.c.id.label('task_id'), func.count(message_t.c.id).label('props_cnt')], from_obj=[j], group_by=[task_t.c.id]).alias('prop_c_s') jjj = join(task_t, jj, task_t.c.id == jj.c.task_id) # jjj = outerjoin(task_effort_t, jjj, task_effort_t.c.task_id == jjj.c.task_id)
class cls(object):pass props =dict(type=relation(Task_Type, lazy=False)) cls.mapper = mapper( cls, jjj, order_by=[desc(task_t.c.updated)], properties=props) #works cls.mapper.properties = {} for t in session.query(cls.mapper).limit(10).offset(0).list(): print t.id, t.title, t.props_cnt # works for t in select([jjj], from_obj=[jjj], limit=10, offset=0).execute(bind_to=session.bind_to): print t.id, t.title, t.props_cnt orm.clear_mapper(cls.mapper) cls.mapper = mapper( cls, jjj, order_by=[desc(task_t.c.updated)], properties=props) # not works for t in session.query(cls.mapper).limit(10).offset(0).list(): print t.id, t.title, t.props_cnt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---