#NEWLINE# def test_single_colsonbase( self ) : #NEWLINE# #INDENT# 'test single inheritance where all the columns are on the base\n        class.' #NEWLINE# class Company ( Base , fixtures . ComparableEntity ) : #NEWLINE# #INDENT# __tablename__ = 'companies' #NEWLINE# id = Column ( 'id' , Integer , primary_key = True , test_needs_autoincrement = True ) #NEWLINE# name = Column ( 'name' , String ( 50 ) ) #NEWLINE# employees = relationship ( 'Person' ) #NEWLINE# #UNINDENT# class Person ( Base , fixtures . ComparableEntity ) : #NEWLINE# #INDENT# __tablename__ = 'people' #NEWLINE# id = Column ( 'id' , Integer , primary_key = True , test_needs_autoincrement = True ) #NEWLINE# company_id = Column ( 'company_id' , Integer , ForeignKey ( 'companies.id' ) ) #NEWLINE# name = Column ( 'name' , String ( 50 ) ) #NEWLINE# discriminator = Column ( 'type' , String ( 50 ) ) #NEWLINE# primary_language = Column ( 'primary_language' , String ( 50 ) ) #NEWLINE# golf_swing = Column ( 'golf_swing' , String ( 50 ) ) #NEWLINE# __mapper_args__ = { #NEWLINE# #INDENT# 'polymorphic_on' : discriminator , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# class Engineer ( Person ) : #NEWLINE# #INDENT# __mapper_args__ = { #NEWLINE# #INDENT# 'polymorphic_identity' : 'engineer' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# class Manager ( Person ) : #NEWLINE# #INDENT# __mapper_args__ = { #NEWLINE# #INDENT# 'polymorphic_identity' : 'manager' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# Base . metadata . create_all ( ) #NEWLINE# sess = create_session ( ) #NEWLINE# c1 = Company ( name = 'MegaCorp, Inc.' , employees = [ Engineer ( name = 'dilbert' , primary_language = 'java' ) , Engineer ( name = 'wally' , primary_language = 'c++' ) , Manager ( name = 'dogbert' , golf_swing = 'fore!' ) ] ) #NEWLINE# c2 = Company ( name = 'Elbonia, Inc.' , employees = [ Engineer ( name = 'vlad' , primary_language = 'cobol' ) ] ) #NEWLINE# sess . add ( self ) #NEWLINE# sess . add ( c2 ) #NEWLINE# sess . flush ( ) #NEWLINE# sess . expunge_all ( ) #NEWLINE# eq_ ( sess . query ( Person ) . filter ( ( Engineer . primary_language == 'cobol' ) ) . first ( ) , Engineer ( name = 'vlad' ) ) #NEWLINE# eq_ ( sess . query ( Company ) . filter ( Company . employees . of_type ( Engineer ) . any ( ( Engineer . primary_language == 'cobol' ) ) ) . first ( ) , c2 )