Changeset 319

Show
Ignore:
Timestamp:
04/03/08 10:12:30 (7 years ago)
Author:
ged
Message:

- Fixed ManyToOne relationships using 'key' kwarg in their column_kwargs

(patch by Jason R. Coombs)

- drop tables after test_through test

Location:
elixir/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/CHANGES

    r318 r319  
    33Bug fixes: 
    44- Fixed multi-table inheritance when using a non default schema (closes #38) 
     5- Fixed ManyToOne relationships using 'key' kwarg in their column_kwargs 
     6  (patch by Jason R. Coombs)  
    57 
    680.5.2 - 2008-03-28 
  • elixir/trunk/elixir/relationships.py

    r307 r319  
    572572 
    573573                # store the names of those columns 
    574                 fk_colnames.append(colname) 
     574                fk_colnames.append(col.key) 
    575575 
    576576                # build the list of column "paths" the foreign key will  
  • elixir/trunk/tests/test_m2o.py

    r273 r319  
    5151 
    5252        assert b.a.testx == 1 
     53 
     54    def test_wh_key_in_m2o_col_kwargs(self): 
     55        class A(Entity): 
     56            name = Field(String(128), default="foo") 
     57         
     58        class B(Entity): 
     59            # specify a different key for the column so that 
     60            #  it doesn't override the property when the column 
     61            #  gets created. 
     62            a = ManyToOne('A', colname='a', 
     63                          column_kwargs=dict(key='a_id')) 
     64          
     65        setup_all(True) 
     66 
     67        assert A.table.primary_key.columns.has_key('id') 
     68        assert B.table.columns.has_key('a_id') 
     69 
     70        a = A() 
     71        session.flush() 
     72        b = B(a=a) 
     73        session.flush() 
     74        session.clear() 
     75 
     76        assert B.query.first().a == A.query.first() 
    5377 
    5478    def test_one_pk(self): 
  • elixir/trunk/tests/test_through.py

    r226 r319  
    11""" 
    2     simple test case 
     2    test has_*(..., through=...) syntax 
    33""" 
    44 
     
    1212class TestThrough(object): 
    1313    def teardown(self): 
    14         cleanup_all() 
     14        cleanup_all(True) 
    1515     
    1616    def test_rel_through(self):