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
Describe the bug
An error occurs in the merge_models function after defining a new field in the document update in the .update method that is not included in the pydantic model using the extra='allow' option.
Traceback (most recent call last):
File "/home/myuser/Documents/.gits/myproject/test.py", line 402, in <module>
asyncio.run(main())
File "/home/myuser/.pyenv/versions/3.11.10/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/home/myuser/.pyenv/versions/3.11.10/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/myuser/.pyenv/versions/3.11.10/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/myuser/Documents/.gits/myproject/test.py", line 397, in main
await doc.update({"$set": {"my_extra_field": 12345}})
File "/home/myuser/.cache/pypoetry/virtualenvs/myproject-B1nOShX4-py3.11/lib/python3.11/site-packages/beanie/odm/actions.py", line 239, in wrapper
result = await f(
^^^^^^^^
File "/home/myuser/.cache/pypoetry/virtualenvs/myproject-B1nOShX4-py3.11/lib/python3.11/site-packages/beanie/odm/utils/state.py", line 85, in wrapper
result = await f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/myuser/.cache/pypoetry/virtualenvs/myproject-B1nOShX4-py3.11/lib/python3.11/site-packages/beanie/odm/documents.py", line 740, in update
merge_models(self, result)
File "/home/myuser/.cache/pypoetry/virtualenvs/myproject-B1nOShX4-py3.11/lib/python3.11/site-packages/beanie/odm/utils/parsing.py", line 27, in merge_models
left_value = getattr(left, k)
^^^^^^^^^^^^^^^^
File "/home/myuser/.cache/pypoetry/virtualenvs/myproject-B1nOShX4-py3.11/lib/python3.11/site-packages/pydantic/main.py", line 856, in __getattr__
raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'DocumentTestModelWithModelConfigExtraAllow' object has no attribute 'my_extra_field'
The text was updated successfully, but these errors were encountered:
Describe the bug
An error occurs in the merge_models function after defining a new field in the document update in the .update method that is not included in the pydantic model using the extra='allow' option.
Follow the code example below and the exception
To Reproduce
Exception
The text was updated successfully, but these errors were encountered: