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).

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to