Changeset 534 for elixir/trunk/tests

Show
Ignore:
Timestamp:
01/29/11 20:53:10 (16 months ago)
Author:
ged
Message:

- Fixed bad foreign key constraint generated for classes inheriting from a

class with multiple primary keys when using the "multi" inheritance.
Patch from & closes #114.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/tests/test_inherit.py

    r490 r534  
    88def setup(): 
    99    metadata.bind = 'sqlite://' 
    10 #    metadata.bind = 'postgres://@/test' 
     10#    metadata.bind = 'postgresql://@/test' 
    1111#    metadata.bind.echo = True 
    1212    elixir.options_defaults['shortnames'] = True 
     
    144144        setup_all() 
    145145 
     146    def test_multi_pk(self): 
     147        class A(Entity): 
     148            using_options(inheritance='multi') 
     149            firstname = Field(String(50), primary_key=True) 
     150            lastname = Field(String(50), primary_key=True) 
     151 
     152        class B(A): 
     153            using_options(inheritance='multi') 
     154 
     155        setup_all(True) 
     156 
     157        b1 = B(firstname='1', lastname='b') 
     158        b2 = B(firstname='2', lastname='b') 
     159 
     160        session.commit() 
     161 
     162        b1.delete() 
     163 
     164        session.commit() 
     165 
     166        assert len(B.query.all()) == 1 
     167 
    146168    def test_multitable_polymorphic_load(self): 
    147169        class A(Entity):