#NEWLINE# @ testing . skip_if ( ( lambda : testing . against ( 'oracle' ) ) , 'Test has an empty insert in it at the moment' ) #NEWLINE# def test_columns_single_inheritance_conflict_resolution( self ) : #NEWLINE# #INDENT# 'Test that a declared_attr can return the existing column and it will\n        be ignored.  this allows conditional columns to be added.\n\n        See [ticket:2472].\n\n        ' #NEWLINE# class Person ( Base ) : #NEWLINE# #INDENT# __tablename__ = 'person' #NEWLINE# id = Column ( Integer , primary_key = True ) #NEWLINE# #UNINDENT# class Engineer ( Person ) : #NEWLINE# #INDENT# 'single table inheritance' #NEWLINE# @ declared_attr #NEWLINE# def target_id( cls ) : #NEWLINE# #INDENT# return cls . __table__ . c . get ( 'target_id' , Column ( Integer , ForeignKey ( 'other.id' ) ) ) #NEWLINE# #UNINDENT# @ declared_attr #NEWLINE# def target( cls ) : #NEWLINE# #INDENT# return relationship ( 'Other' ) #NEWLINE# #UNINDENT# #UNINDENT# class Manager ( Person ) : #NEWLINE# #INDENT# 'single table inheritance' #NEWLINE# @ declared_attr #NEWLINE# def target_id( cls ) : #NEWLINE# #INDENT# return cls . __table__ . c . get ( 'target_id' , Column ( Integer , ForeignKey ( 'other.id' ) ) ) #NEWLINE# #UNINDENT# @ declared_attr #NEWLINE# def target( cls ) : #NEWLINE# #INDENT# return relationship ( 'Other' ) #NEWLINE# #UNINDENT# #UNINDENT# class Other ( Base ) : #NEWLINE# #INDENT# __tablename__ = 'other' #NEWLINE# id = Column ( Integer , primary_key = True ) #NEWLINE# #UNINDENT# is_ ( Engineer . target_id . property . columns [ 0 ] , Person . __table__ . c . target_id ) #NEWLINE# is_ ( Manager . target_id . property . columns [ 0 ] , Person . __table__ . c . target_id ) #NEWLINE# Base . metadata . create_all ( ) #NEWLINE# session = Session ( ) #NEWLINE# ( o1 , o2 ) = ( Other ( ) , Other ( ) ) #NEWLINE# session . add_all ( [ Engineer ( target = o1 ) , Manager ( target = o2 ) , Manager ( target = o1 ) ] ) #NEWLINE# session . commit ( ) #NEWLINE# eq_ ( session . query ( Engineer ) . first ( ) . target , o2 )