not function correctly in conjunction with a mapping that
implements a version id counter.
+ .. 3778
+
+ .. change::
+ :tickets: 3778
+ :versions: 1.1.4
+
+ Fixed bug where the :attr:`.Mapper.attrs`,
+ :attr:`.Mapper.all_orm_descriptors` and other derived attributes would
+ fail to refresh when mapper properties or other ORM constructs were
+ added to the mapper/class after these accessors were first called.
+
.. changelog::
:version: 1.0.15
:released: September 1, 2016
continue
yield c
- @util.memoized_property
+ @_memoized_configured_property
def attrs(self):
"""A namespace of all :class:`.MapperProperty` objects
associated this mapper.
configure_mappers()
return util.ImmutableProperties(self._props)
- @util.memoized_property
+ @_memoized_configured_property
def all_orm_descriptors(self):
"""A namespace of all :class:`.InspectionAttr` attributes associated
with the mapped class.
)
assert 'name' in u1.__dict__
+ def test_attrs_props_prop_added_after_configure(self):
+ class AnonClass(object):
+ pass
+
+ from sqlalchemy.orm import mapper, column_property
+ from sqlalchemy.ext.hybrid import hybrid_property
+ m = mapper(AnonClass, self.tables.users)
+
+ eq_(
+ set(inspect(AnonClass).attrs.keys()),
+ set(['id', 'name']))
+ eq_(
+ set(inspect(AnonClass).all_orm_descriptors.keys()),
+ set(['id', 'name']))
+
+ m.add_property('q', column_property(self.tables.users.c.name))
+
+ def desc(self):
+ return self.name
+ AnonClass.foob = hybrid_property(desc)
+
+ eq_(
+ set(inspect(AnonClass).attrs.keys()),
+ set(['id', 'name', 'q']))
+ eq_(
+ set(inspect(AnonClass).all_orm_descriptors.keys()),
+ set(['id', 'name', 'q', 'foob']))
+
def test_instance_state_ident_transient(self):
User = self.classes.User
u1 = User(name='ed')