- changed status to resolved
overriding different columns with the same key during inheritance
Issue #1111
resolved
r4952 commits a basic proof of the issue, which looks like:
base = Table('base', metadata,
Column('base_id', Integer, primary_key=True),
Column('data', String(255))
)
subtable = Table('subtable', metadata,
Column('base_id', Integer, ForeignKey('base.base_id'), primary_key=True),
Column('subdata', String(255))
)
class Base(object):
pass
class Sub(Base):
pass
mapper(Base, base, properties={
'id':base.c.base_id
})
mapper(Sub, subtable, inherits=Base, properties={
'id':subtable.c.base_id
})
# what in fact happens is that "Sub" gets the column "base_id" mapped
# as well. what *should* happen is, Sub mapper should reconcile
# the inherited "id" from Base. right now Base's "id" is ignored
# totally because the same key is present in Sub.
self.assertEquals(
class_mapper(Sub).get_property('id').columns,
[subtable.c.base_id](base.c.base_id,)
)
# this fails too
s1 = Sub()
s1.id = 10
sess = create_session()
sess.add(s1)
sess.flush()
assert sess.query(Sub).get(10) is s1
this can come up pretty easily when using Declarative.
Comments (2)
-
reporter -
reporter - removed milestone
Removing milestone: 0.5.xx (automated comment)
- Log in to comment
hooray, 5af88c5df1f26d60becc8c60f7d99b3278e7c220