#NEWLINE# def test_basic( self ) : #NEWLINE# #INDENT# class Foo ( object ) : #NEWLINE# #INDENT# def __init__( self , data = None ) : #NEWLINE# #INDENT# self . data = data #NEWLINE# #UNINDENT# def __repr__( self ) : #NEWLINE# #INDENT# return ( 'Foo id %d, data %s' % ( self . id , self . data ) ) #NEWLINE# #UNINDENT# #UNINDENT# mapper ( Foo , foo ) #NEWLINE# class Bar ( Foo ) : #NEWLINE# #INDENT# def __repr__( self ) : #NEWLINE# #INDENT# return ( 'Bar id %d, data %s' % ( self . id , self . data ) ) #NEWLINE# #UNINDENT# #UNINDENT# mapper ( Bar , bar , inherits = Foo ) #NEWLINE# class Blub ( Bar ) : #NEWLINE# #INDENT# def __repr__( self ) : #NEWLINE# #INDENT# return ( 'Blub id %d, data %s' % ( self . id , self . data ) ) #NEWLINE# #UNINDENT# #UNINDENT# mapper ( Blub , blub , inherits = Bar , properties = { #NEWLINE# #INDENT# 'parent_foo' : relationship ( Foo ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# sess = create_session ( ) #NEWLINE# b1 = Blub ( 'blub #1' ) #NEWLINE# b2 = Blub ( 'blub #2' ) #NEWLINE# f = Foo ( 'foo #1' ) #NEWLINE# sess . add ( b1 ) #NEWLINE# sess . add ( b2 ) #NEWLINE# sess . add ( f ) #NEWLINE# b1 . parent_foo = f #NEWLINE# b2 . parent_foo = f #NEWLINE# sess . flush ( ) #NEWLINE# compare = ',' . join ( [ repr ( b2 ) , repr ( b2 ) , repr ( b1 . parent_foo ) , repr ( b2 . parent_foo ) ] ) #NEWLINE# sess . expunge_all ( ) #NEWLINE# l = sess . query ( Blub ) . all ( ) #NEWLINE# result = ',' . join ( [ repr ( l [ 0 ] ) , repr ( l [ 1 ] ) , repr ( l [ 0 ] . parent_foo ) , repr ( l [ 1 ] . parent_foo ) ] ) #NEWLINE# eq_ ( compare , result ) #NEWLINE# eq_ ( l [ 0 ] . parent_foo . data , 'foo #1' ) #NEWLINE# eq_ ( l [ 1 ] . parent_foo . data , 'foo #1' )