Changeset 302

Show
Ignore:
Timestamp:
02/07/08 14:30:31 (5 years ago)
Author:
ged
Message:
  • Fixed the inverse relationship matching when the inverse relationship is
    defined in a parent Entity (thanks to Alexandre da Silva).
Location:
elixir/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/CHANGES

    r301 r302  
    2222  options) if it doesn't use any statement itself. 
    2323- Made inheritance work for custom base classes (closes #25). 
     24- Fixed the inverse relationship matching when the inverse relationship is  
     25  defined in a parent Entity (thanks to Alexandre da Silva). 
    2426- Fixed bug in setup_entities (it always used the global entity list and not 
    2527  the list given as argument). 
  • elixir/trunk/elixir/entity.py

    r300 r302  
    530530                return rel 
    531531        if self.parent: 
    532             return self.parent.find_relationship(name) 
     532            return self.parent._descriptor.find_relationship(name) 
    533533        else: 
    534534            return None 
  • elixir/trunk/tests/test_inherit.py

    r300 r302  
    6565        cleanup_all(True) 
    6666 
    67     def test_singletable_inheritance(self): 
    68         do_tst('single', False, True, { 
    69             'A': ('A', 'A', 'A', 'A', 'A'), 
    70             'B': ('B', 'B', 'B', 'B', 'B'), 
    71             'C': ('C', 'C', 'C', 'C', 'C'), 
    72             'D': ('D', 'D', 'D', 'D', 'D'), 
    73             'E': ('E', 'E', 'E', 'E', 'E') 
    74         }) 
    75  
    7667    # this is related to SA ticket 866  
    7768    # http://www.sqlalchemy.org/trac/ticket/866 
     
    113104#        assert not B.table.select().execute().fetchall() 
    114105 
     106    def test_inverse_matching_on_parent(self): 
     107        options_defaults['inheritance'] = 'multi' 
     108 
     109        class Person(Entity): 
     110            using_options(inheritance='multi') 
     111 
     112            name = Field(UnicodeText) 
     113 
     114        class Parent(Person): 
     115            using_options(inheritance='multi') 
     116            childs = ManyToMany('Child', tablename='child_parent', 
     117                                inverse='parents') 
     118 
     119        class Child(Person): 
     120            using_options(inheritance='multi') 
     121 
     122            parents = ManyToMany('Parent', tablename='child_parent', 
     123                                 inverse='childs') 
     124 
     125        setup_all() 
     126 
     127    def test_singletable_inheritance(self): 
     128        do_tst('single', False, True, { 
     129            'A': ('A', 'A', 'A', 'A', 'A'), 
     130            'B': ('B', 'B', 'B', 'B', 'B'), 
     131            'C': ('C', 'C', 'C', 'C', 'C'), 
     132            'D': ('D', 'D', 'D', 'D', 'D'), 
     133            'E': ('E', 'E', 'E', 'E', 'E') 
     134        }) 
     135 
    115136    def test_polymorphic_singletable_inheritance(self): 
    116137        do_tst('single', True, True, {