#NEWLINE# def test_from_aliased( self ) : #NEWLINE# #INDENT# ( users , Dingaling , User , dingalings , Address , addresses ) = ( self . tables . users , self . classes . Dingaling , self . classes . User , self . tables . dingalings , self . classes . Address , self . tables . addresses ) #NEWLINE# mapper ( Dingaling , dingalings ) #NEWLINE# mapper ( Address , addresses , properties = { #NEWLINE# #INDENT# 'dingalings' : relationship ( Address , order_by = Dingaling . id ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# mapper ( User , users , properties = { #NEWLINE# #INDENT# 'addresses' : relationship ( Address , order_by = Address . id ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# sess = create_session ( ) #NEWLINE# u = aliased ( User ) #NEWLINE# q = sess . query ( u ) . options ( subqueryload ( u . addresses ) ) #NEWLINE# def go( ) : #NEWLINE# #INDENT# eq_ ( [ User ( id = 7 , addresses = [ Address ( id = 1 , email_address = 'jack@bean.com' ) ] ) ] , q . filter ( ( u . id == 7 ) ) . all ( ) ) #NEWLINE# #UNINDENT# self . assert_sql_count ( testing . db , go , 2 ) #NEWLINE# def go( ) : #NEWLINE# #INDENT# eq_ ( self . static . user_address_result , q . order_by ( u . id ) . all ( ) ) #NEWLINE# #UNINDENT# self . assert_sql_count ( testing . db , go , 2 ) #NEWLINE# q = sess . query ( u ) . options ( subqueryload_all ( u . addresses , Address . dingalings ) ) #NEWLINE# def go( ) : #NEWLINE# #INDENT# eq_ ( [ User ( id = 8 , addresses = [ Address ( id = 2 , email_address = 'ed@wood.com' , dingalings = [ Dingaling ( ) ] ) , Address ( id = 3 , email_address = 'ed@bettyboop.com' ) , Address ( id = 4 , email_address = 'ed@lala.com' ) ] ) , User ( id = 9 , addresses = [ Address ( id = 5 , dingalings = [ Dingaling ( ) ] ) ] ) ] , q . filter ( u . id . in_ ( [ 8 , 9 ] ) ) . all ( ) ) #NEWLINE# #UNINDENT# self . assert_sql_count ( testing . db , go , 3 )