#NEWLINE# def test_orderby_related( self ) : #NEWLINE# #INDENT# 'A regular mapper select on a single table can\n            order by a relationship to a second table' #NEWLINE# ( Address , addresses , users , User ) = ( self . classes . Address , self . tables . addresses , self . tables . users , self . classes . User ) #NEWLINE# mapper ( Address , addresses ) #NEWLINE# mapper ( User , users , properties = dict ( addresses = relationship ( Address , lazy = 'subquery' , order_by = addresses . c . id ) ) ) #NEWLINE# q = create_session ( ) . query ( User ) #NEWLINE# l = q . filter ( ( User . id == Address . user_id ) ) . order_by ( Address . email_address ) . all ( ) #NEWLINE# eq_ ( [ User ( id = 8 , addresses = [ Address ( id = 2 , email_address = 'ed@wood.com' ) , Address ( id = 3 , email_address = 'ed@bettyboop.com' ) , Address ( id = 4 , email_address = 'ed@lala.com' ) ] ) , User ( id = 9 , addresses = [ Address ( id = 5 ) ] ) , User ( id = 7 , addresses = [ Address ( id = 1 ) ] ) ] , l )