I want to query specific objects of Reference. But I want that list ordered by its child objects (you could say relation): Reference._periodical._name and `Reference._author._lastname'.
Can not see how to do this. Not sure if this is even possible? This is the query but without the ordering in it. return self.session.query(Reference) \ .filter_by(_mark = False) \ #.order_by(paModel_sqla.Reference._periodical) \ #.order_by(paModel_sqla.Reference._author._lastname) \ .all() This is the (simplified) model itself ReferenceAuthor = sa.Table('ReferenceAuthor', _Base.metadata, sa.Column('ReferenceID', sa.Integer, sa.ForeignKey('Reference.ID'), primary_key=True), sa.Column('PersonID', sa.Integer, sa.ForeignKey('Person.ID'), primary_key=True), sa.Column('Index', sa.Integer) ) class Reference(_Base): __tablename__ = 'Reference' _id = sa.Column('ID', sa.Integer, primary_key=True) _mark = sa.Column('HasLabel', sa.Boolean) # Autor _authors = sao.relationship('Person', secondary=ReferenceAuthor, order_by=ReferenceAuthor.c.Index) # Journal _periodical_fk = sa.Column('PeriodicalID', sa.Integer, sa.ForeignKey('Periodical.ID')) _periodical = sao.relationship('Periodical') class Periodical(_Base): __tablename__ = 'Periodical' _id = sa.Column('ID', sa.Integer, primary_key=True) _name = sa.Column('Name', sa.String) class Person(_Base): __tablename__ = 'Person' _id = sa.Column('ID', sa.Integer, primary_key=True) _lastname = sa.Column('LastName', sa.String) -- Verfassungsbeschwerden gegen Vorratsdatenspeicherung <https://digitalcourage.de/weg-mit-vds> Dein Recht zu unterzeichnen! -- 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. For more options, visit https://groups.google.com/d/optout.