cant add backrefs/use add_property against mappers with inheriting children

Issue #154 resolved
Mike Bayer repo owner created an issue

because an inheritance relationship copies the properties from the base mapper to the child mapper at construction time, an add_property on the base mapper fails to propigate to the child mapper. this is most apparent when creating a backref against the base mapper:

        content_type = Table('content_type', engine, 
            Column('id', Integer, primary_key=True)
            )
        content = Table('content', engine,
            Column('id', Integer, primary_key=True),
            Column('content_type_id', Integer, ForeignKey('content_type.id'))
            )
        product = Table('product', engine, 
            Column('id', Integer, ForeignKey('content.id'), primary_key=True)
        )
        class ContentType(object): pass
        class Content(object): pass
        class Product(Content): pass

        # this test fails currently
        contents = mapper(Content, content)
        products = mapper(Product, product, inherits=contents)
        content_types = mapper(ContentType, content_type, properties={
            'content':relation(contents, backref='contenttype')
        })
        p = Product()
        p.contenttype = ContentType()

Comments (1)

  1. Log in to comment