Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating field of EmbeddedModel rises AttributeError: __fields_modified__ #51

Closed
benyaming opened this issue Nov 16, 2020 · 2 comments · Fixed by #40
Closed

Updating field of EmbeddedModel rises AttributeError: __fields_modified__ #51

benyaming opened this issue Nov 16, 2020 · 2 comments · Fixed by #40
Labels
bug Something isn't working

Comments

@benyaming
Copy link

Here is simple example:

from abc import ABC
from typing import List

from odmantic import Model, EmbeddedModel, Field


class Address(EmbeddedModel, ABC):
    address: str


class TestUser(Model, ABC):
    addresses: List[Address]


user = TestUser(addresses=[Address(address='Israel')])
user.addresses[0].address = 'Russia'  # will raise AttributeError: __fields_modified__

----------------------------------

Traceback (most recent call last):
  File "C:/Users/Benyamin/etc/zmanim_bot/zmanim_bot/api/test.py", line 16, in <module>
    user.addresses[0].address = 'Russia'  # will raise AttributeError: __fields_modified__
  File "C:\Users\Benyamin\.virtualenvs\zmanim_bot-luq9P_0V\lib\site-packages\odmantic\model.py", line 507, in __setattr__
    self.__fields_modified__.add(name)
AttributeError: __fields_modified__
@art049
Copy link
Owner

art049 commented Nov 16, 2020

Yes #40 fixes this as a side effect 😄 i'll make a patch release in few hours.

@art049 art049 linked a pull request Nov 16, 2020 that will close this issue
@art049 art049 added the bug Something isn't working label Nov 16, 2020
@benyaming
Copy link
Author

Works now! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants