How to order a table by fields of an other table connected to the first one by ForeignKey()

Paul Otto Seidon <[email protected]> Thu, 7 Jan 2016 15:03:22 +0000 (UTC)
Newsgroups gmane.comp.python.sqlobject
Message-ID <[email protected]>
Hi all,

this seems somehow related to a recent post asking about "querying for 
foreign key". Here as well, I guess, tables have to be joined, but I 
don't see how to pack this into a single ORDERBY clause.

The main table is Entry, which owns _status = ForeignKey( "Status"). 
Status owns a field 'value' besides some other fields. Now I would like 
the Entry rows I select by some other criterion (e.g. their priority) be 
ordered by the value field of the Status of the Entry.

When I ORDERBY Status.q._value then SQLOBJECT correctly tells me, that 
Entry doesn't own a _value field. All other combinations don't work 
neither. 

This has to be done more SQL-ish, right?

Anyone willing to help me out here?

Cheers
Paul



------------------------------------------------------------------------------