Ok I just identified the issue. It seems that there is a conflict between 2 subqueries :
in my model.I have this : statussen = relationship( "PersoonStatus", order_by="desc(PersoonStatus.status_datum)", backref='persoon', cascade='all, delete, delete-orphan', lazy='subquery' ) and if I do this query : last_statuses = aliased( statussen_table_name, self.session.query( getattr(statussen_table_name, issue_id_field), statussen_table_name.status_id)\ .join(Status).order_by(Status.datum.desc())\ .limit(1).subquery().lateral()) there is a conflict between this 2 subqueries who target the same table. Is there a workaround to prevent this conflict? any idea? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/61df1e98-8475-4d3a-a21b-20aff412d4fa%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.