Hi!
I have two tables: A and B defined something like that:
A:
Column('id', Integer, primary_key=True),
Column('name', Unicode(256)),
Column('b_id', Integer, ForeignKey('
b.id'))
B:
Column('id', Integer, primary_key=True),
Column('name', Unicode(256)),
mapper of A is created with:
properties={
'b': relation(B, primaryjoin=A.b_id == B.id, lazy=False),
}
(lazy = False is important in this case)
How can I select all elements from A sorted by B.name? I checked that
I can't use
SESSION.query(A).order_by(B.name)
because it's not working - query(A) consist of JOIN with B table and B
table has alias B_1 in this query and sqlalchemy interprets
order_by(B.name) as ORDER BY B.name but there is no B alias in
query(A).