- attached properties_inheritance_broken.py
properties added after a declarative class has been defined are incorrectly propagated to child classes.
Issue #1570
resolved
We are using a declarative mapper:
Base = sqlalchemy.ext.declarative.declarative_base(mapper=sqlalchemy.orm.mapper)
In a situation with two classes:
class Foo(Base):
and
class Bar(Foo):
appending a new Column to the parent class:
Foo.attr = sqlalchemy.Column(sqlalchemy.types.Integer)
before:
Base.metadata.create_all()
results in a badly behaving property of the class Bar (as shown in the attached test), which doesn't preserve its value after a commit. The property works ok when added in Foo class definition.
Comments (4)
-
Account Deleted -
Account Deleted - attached properties_inheritance_ok.py
Adding property in definition (test passes).
-
repo owner the fix here is targeted at 0.5.7 and 0.6 and is in 6535456ea6eabb5b0fa5a76abfb14cc7f663bd75 82cf74d5154efd7bbae12658a45b80c5b7c08635. It is the complimentary version of the fix for
#1523. It goes through extra effort to work for more than one level of inheritance as well. -
repo owner - removed milestone
Removing milestone: 0.5.7 (automated comment)
- Log in to comment
Adding property after definition (test fails).