Changeset 433 for elixir/trunk

Show
Ignore:
Timestamp:
12/17/08 16:01:02 (3 years ago)
Author:
ged
Message:

revert part of previous commit... SA can't possibly compute itself the
inherit_condition when there are several FK from the child table to the parent
table

Location:
elixir/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/elixir/entity.py

    r432 r433  
    4444        self.module = sys.modules.get(entity.__module__) 
    4545 
     46        # used for multi-table inheritance 
     47        self.join_condition = None 
    4648        self.has_pk = False 
    4749        self._pk_col_done = False 
     
    175177                    parent_desc = self.parent._descriptor 
    176178                    tablename = parent_desc.table_fullname 
     179                    join_clauses = [] 
    177180                    for pk_col in parent_desc.primary_keys: 
    178181                        colname = options.MULTIINHERITANCECOL_NAMEFORMAT % \ 
     
    188191                                     primary_key=True) 
    189192                        self.add_column(col) 
     193                        join_clauses.append(col == pk_col) 
     194                    self.join_condition = and_(*join_clauses) 
    190195                elif self.inheritance == 'concrete': 
    191196                    # Copy primary key columns from the parent. 
     
    379384                # non-polymorphic concrete doesn't need this 
    380385                kwargs['inherits'] = self.parent.mapper 
     386 
     387            if self.inheritance == 'multi' and self.parent: 
     388                kwargs['inherit_condition'] = self.join_condition 
    381389 
    382390            if self.polymorphic: 
  • elixir/trunk/tests/test_inherit.py

    r432 r433  
    158158            data = Field(String(50)) 
    159159            some_c = ManyToOne('C') 
     160            some_a = ManyToOne('A') 
    160161 
    161162        class C(A): 
     
    174175        for a in A.query.all(): 
    175176            if isinstance(a, (B, C)): 
     177                # On SA 0.4.x, this test works whether with_polymorphic is 
     178                # specified or not, because in 0.4.x, without with_polymorphic, 
     179                # it issues as many queries as necessary to load all data, 
     180                # while in 0.5, columns are "deferred". 
    176181                assert 'data' in a.__dict__ 
    177182