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

Can't change a field in a copied embedded model that's part of a collection #228 #321

Open
bartoszflis-silvair opened this issue Jan 16, 2023 · 0 comments · May be fixed by #322
Open

Can't change a field in a copied embedded model that's part of a collection #228 #321

bartoszflis-silvair opened this issue Jan 16, 2023 · 0 comments · May be fixed by #322
Labels
bug Something isn't working

Comments

@bartoszflis-silvair
Copy link

bartoszflis-silvair commented Jan 16, 2023

Bug

Given a model definition like this:

class E(EmbeddedModel):
    f: int

class M(Model):
    e: List[E]

model = M(e=[E(f=1)])
copy = instance.copy(deep=True)

When I call copy.e[0].f = 2
Then an AttributeError: 'E' object has no attribute '__fields_modified__' occurs

Environment

  • ODMantic version: 0.9.2
  • MongoDB version: 5.0.9
  • Pydantic infos (output of python -c "import pydantic.utils; print(pydantic.utils.version_info())"):
            pydantic version: 1.9.1
            pydantic compiled: True
                 install path: /lib/python3.10/site-packages/pydantic
               python version: 3.10.4 (main, May  9 2022, 12:55:22) [GCC 9.3.0]
                     platform: Linux-5.4.0-73-generic-x86_64-with-glibc2.31
     optional deps. installed: ['typing-extensions']

Additional context

This is a continuation of #228 .

@bartoszflis-silvair bartoszflis-silvair added the bug Something isn't working label Jan 16, 2023
bartoszflis-silvair added a commit to SilvairGit/odmantic that referenced this issue Jan 16, 2023
bartoszflis-silvair added a commit to SilvairGit/odmantic that referenced this issue Jan 17, 2023
Find all instances of _BaseODMModel subclasses, including those stored
in lists or tuples, and set the required attribute on them during copy.

Fixes art049#321.
bartoszflis-silvair added a commit to SilvairGit/odmantic that referenced this issue Jan 18, 2023
Find all instances of _BaseODMModel subclasses, including those stored
in lists or tuples, and set the required attribute on them during copy.

Fixes art049#321.
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.

1 participant