-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
Hi, all!
I've faced with issue after upgrading eve-sqlalchemy from 0.4.1 to 0.7.1.
My package versions are following:
- flask==0.12
- sqlalchemy==1.3
- Eve==0.7.2
- Eve-sqlalchemy==0.7.1
One of my model has relation and hybrid_property:
class PrivateAccount:
_user_id = Column('_user_id')
user = relationship('User')
@hybrid_property
def name(self):
if self.user:
return '{} {}'.format(self.user.firstname, self.user.lastname)
DOMAIN = DomainConfig({
'private_account': ResourceConfig(PrivateAccount),
}).render()
I got an error when domain is building
DOMAIN = DomainConfig({
DOMAIN = DomainConfig({
File "/home/user/.pyenv/versions/test_env/lib/python3.9/site-packages/eve_sqlalchemy/config/domainconfig.py", line 63, in render
domain_def[endpoint] = resource_config.render(
File "/home/user/.pyenv/versions/test_env/lib/python3.9/site-packages/eve_sqlalchemy/config/resourceconfig.py", line 58, in render
field_configs = self._create_field_configs()
File "/home/user/.pyenv/versions/test_env/lib/python3.9/site-packages/eve_sqlalchemy/config/resourceconfig.py", line 141, in _create_field_configs
hybrid_properties = {
File "/home/user/.pyenv/versions/test_env/lib/python3.9/site-packages/eve_sqlalchemy/config/resourceconfig.py", line 142, in <dictcomp>
k: HybridPropertyFieldConfig(k, self.model, self._mapper)
File "/home/user/.pyenv/versions/test_env/lib/python3.9/site-packages/eve_sqlalchemy/config/fieldconfig.py", line 16, in __init__
self._field = getattr(model, name)
File "/home/user/.pyenv/versions/test_env/lib/python3.9/site-packages/sqlalchemy/ext/hybrid.py", line 893, in __get__
return self._expr_comparator(owner)
File "/home/user/.pyenv/versions/test_env/lib/python3.9/site-packages/sqlalchemy/ext/hybrid.py", line 1100, in expr_comparator
comparator(owner),
File "/home/user/.pyenv/versions/test_env/lib/python3.9/site-packages/sqlalchemy/ext/hybrid.py", line 1085, in _expr
return ExprComparator(cls, expr(cls), self)
File "/home/user/dev/test_env/models/model_private_account.py", line 71, in name
return '{} {}'.format(self.user.firstname, self.user.lastname)
File "/home/user/.pyenv/versions/test_env/lib/python3.9/site-packages/sqlalchemy/orm/attributes.py", line 223, in __getattr__
raise AttributeError(
AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with PrivateAccount.user has an attribute 'firstname'
As I understood hybrid properties initialized at startup unlike registerSchema mechanism (version 0.4.1).
How to avoid this issue (without using try/except)?
Maybe somebody has solved this before?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels