Changeset 478 for elixir/trunk

Show
Ignore:
Timestamp:
09/29/09 18:53:07 (3 years ago)
Author:
ged
Message:

- Default table_options (defined in options_defaultstable_options?) are now

also used for ManyToMany tables.

Location:
elixir/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/CHANGES

    r477 r478  
    1818- Added (or rather fixed and documented) a "table" argument on ManyToMany 
    1919  relationships to allow using a manually-defined Table (closes #44). 
    20 - Added a "schema" argument on ManyToMany relationships to be able to create  
    21   the ManyToMany table in a custom schema and not necessarily the same schema  
     20- Added a "schema" argument on ManyToMany relationships to be able to create 
     21  the ManyToMany table in a custom schema and not necessarily the same schema 
    2222  as the table of the "source" entity (patch from Diez B. Roggisch). 
    2323- Added a "table_kwargs" argument on ManyToMany relationships to pass any 
     
    5555- Made manually defined mapper options take precedence over Elixir-generated 
    5656  ones. Not very useful yet since most are expecting Column objects. 
     57- Default table_options (defined in options_defaults['table_options']) are now 
     58  also used for ManyToMany tables. 
    5759 
    5860Bug fixes: 
  • elixir/trunk/elixir/relationships.py

    r477 r478  
    915915                return 
    916916 
     917        # compute table_kwargs 
     918        complete_kwargs = options.options_defaults['table_options'].copy() 
     919        complete_kwargs.update(self.table_kwargs) 
     920 
    917921        #needs: table_options['schema'], autoload, tablename, primary_keys, 
    918922        #entity.__name__, table_fullname 
     
    982986 
    983987            self.table = Table(tablename, e1_desc.metadata, autoload=True, 
    984                                **self.table_kwargs) 
     988                               **complete_kwargs) 
    985989            if 'primaryjoin' not in self.kwargs or \ 
    986990               'secondaryjoin' not in self.kwargs: 
     
    10861090 
    10871091            self.table = Table(tablename, e1_desc.metadata, 
    1088                                schema=schema, *args, **self.table_kwargs) 
     1092                               schema=schema, *args, **complete_kwargs) 
    10891093            if DEBUG: 
    10901094                print self.table.repr2() 
  • elixir/trunk/tests/test_m2m.py

    r477 r478  
    5858    def test_table_kwargs(self): 
    5959        class A(Entity): 
    60             using_options(shortnames=True) 
    61             name = Field(String(60)) 
    6260            bs_ = ManyToMany('B', table_kwargs={'info': {'test': True}}) 
    6361 
    6462        class B(Entity): 
    65             using_options(shortnames=True) 
    66             name = Field(String(60)) 
    6763            as_ = ManyToMany('A') 
    6864 
     
    7167 
    7268        assert A.bs_.property.secondary.info['test'] is True 
     69 
     70    def test_table_default_kwargs(self): 
     71        options_defaults['table_options'] = {'info': {'test': True}} 
     72 
     73        class A(Entity): 
     74            bs_ = ManyToMany('B') 
     75 
     76        class B(Entity): 
     77            as_ = ManyToMany('A') 
     78 
     79        setup_all(True) 
     80        A.mapper.compile() 
     81 
     82        options_defaults['table_options'] = {} 
     83 
     84        assert A.bs_.property.secondary.info['test'] is True 
     85        assert A.table.info['test'] is True 
     86        assert B.table.info['test'] is True 
    7387 
    7488    def test_custom_global_column_nameformat(self):