[Sqlalchemy-tickets] Issue #3777: Accessing the history of a synonym attribute (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Konsta V. <iss...@bi...> - 2016-08-20 12:50:06
|
New issue 3777: Accessing the history of a synonym attribute https://bitbucket.org/zzzeek/sqlalchemy/issues/3777/accessing-the-history-of-a-synonym Konsta Vesterinen: Consider the following code: ``` #!python import sqlalchemy as sa from sqlalchemy.ext.declarative import declarative_base, synonym_for Base = declarative_base() class User(Base): __tablename__ = 'user' _name = sa.Column(sa.String, primary_key=True) @synonym_for('_name') @property def name(self): return self._name u = User() sa.inspect(u).attrs['name'].history ``` Currently this raises the following error: ``` #!python Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/sqlalchemy/orm/state.py", line 684, in history PASSIVE_NO_INITIALIZE) File "/sqlalchemy/orm/state.py", line 309, in get_history return self.manager[key].impl.get_history(self, self.dict, passive) AttributeError: '_ProxyImpl' object has no attribute 'get_history' ``` I think it would make more sense if this either 1. Would not raise an AttributeError but rather show the history of the property that the synonym property is pointing at (in this case the history of ``_name``) 2. Raise an error with more descriptive error message This is just a minor issue for me and its easy to find a workaround for this. |