You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrated issue, originally created by Konsta Vesterinen (@kvesteri)
Consider the following code:
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:
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
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)
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.
The text was updated successfully, but these errors were encountered:
if someone is iterating through attributes and calling get_history() on all of them, they're going to get the same history multiple times if they hit the synonym(s) then the real attribute, raising would encourage them to iterate only through primary attributes.
OTOH, we do know the answer to the question "some_synonym.get_history()". would help in pdb situations and such.
it's a strange use case because the synonym is a proxy for the real attribute but it's not included in the persistence operation.
I was leaning towards raise and now im leaning towards implementing. but that's just within a 2 minute span so I'll let this sit out there :)
Migrated issue, originally created by Konsta Vesterinen (@kvesteri)
Consider the following code:
Currently this raises the following error:
I think it would make more sense if this either
_name
)This is just a minor issue for me and its easy to find a workaround for this.
The text was updated successfully, but these errors were encountered: