#NEWLINE# def test_reduce_aliased_union_2( self ) : #NEWLINE# #INDENT# metadata = MetaData ( ) #NEWLINE# page_table = Table ( 'page' , metadata , Column ( 'id' , Integer , primary_key = True ) ) #NEWLINE# magazine_page_table = Table ( 'magazine_page' , metadata , Column ( 'page_id' , Integer , ForeignKey ( 'page.id' ) , primary_key = True ) ) #NEWLINE# classified_page_table = Table ( 'classified_page' , metadata , Column ( 'magazine_page_id' , Integer , ForeignKey ( 'magazine_page.page_id' ) , primary_key = True ) ) #NEWLINE# pjoin = union ( select ( [ page_table . c . id , magazine_page_table . c . page_id , classified_page_table . c . magazine_page_id ] ) . select_from ( page_table . join ( magazine_page_table ) . join ( classified_page_table ) ) , select ( [ page_table . c . id , magazine_page_table . c . page_id , cast ( null ( ) , Integer ) . label ( 'magazine_page_id' ) ] ) . select_from ( page_table . join ( magazine_page_table ) ) ) . alias ( 'pjoin' ) #NEWLINE# eq_ ( util . column_set ( sql_util . reduce_columns ( [ pjoin . c . id , pjoin . c . page_id , pjoin . c . magazine_page_id ] ) ) , util . column_set ( [ pjoin . c . id ] ) ) #NEWLINE# pjoin = union ( select ( [ page_table . c . id , magazine_page_table . c . page_id , cast ( null ( ) , Integer ) . label ( 'magazine_page_id' ) ] ) . select_from ( page_table . join ( magazine_page_table ) ) , select ( [ page_table . c . id , magazine_page_table . c . page_id , classified_page_table . c . magazine_page_id ] ) . select_from ( page_table . join ( magazine_page_table ) . join ( classified_page_table ) ) ) . alias ( 'pjoin' ) #NEWLINE# eq_ ( util . column_set ( sql_util . reduce_columns ( [ pjoin . c . id , pjoin . c . page_id , pjoin . c . magazine_page_id ] ) ) , util . column_set ( [ pjoin . c . id ] ) )