--- /dev/null
+.. change::
+ :tags: bug, orm
+ :tickets: 3777
+
+ Implemented the ``.get_history()`` method, which also implies availability
+ of :attr:`.AttributeState.history`, for :func:`.synonym` attributes.
+ Previously, trying to access attribute history via a synonym would raise an
+ ``AttributeError``.
comp = prop.comparator_factory(prop, mapper)
return comp
+ def get_history(self, *arg, **kw):
+ attr = getattr(self.parent.class_, self.name)
+ return attr.impl.get_history(*arg, **kw)
+
def set_parent(self, parent, init):
if self.map_column:
# implement the 'map_column' option.
u = s.query(User).filter(User.y == 8).one()
eq_(u.y, 8)
+ def test_synonym_get_history(self):
+ users, User = (self.tables.users,
+ self.classes.User)
+
+ mapper(User, users, properties={
+ 'x': synonym('id'),
+ 'y': synonym('x')
+ })
+
+ u1 = User()
+ eq_(attributes.instance_state(u1).attrs.x.history, (None, None, None))
+ eq_(attributes.instance_state(u1).attrs.y.history, (None, None, None))
+
+ u1.y = 5
+ eq_(attributes.instance_state(u1).attrs.x.history, ([5], (), ()))
+ eq_(attributes.instance_state(u1).attrs.y.history, ([5], (), ()))
+
def test_synonym_of_non_property_raises(self):
from sqlalchemy.ext.associationproxy import association_proxy