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
Attempting to create a model instance using Model.model_construct results in __fields_modified__ not being present on the instance, causing AttributeErrors to be raised later when attempting to set attributes on the instance.
Current Behavior
#!/usr/bin/env python3
from datetime import time
# from pydantic import BaseModel
from odmantic import Model
class Test(Model):
foo: time
t = Test(foo=time(1, 2, 3))
print(t)
t.foo = time(4, 5, 6)
print(t)
obj = t.model_dump()
print(obj)
u = Test.model_construct(**obj)
# u = Test(**obj)
print(u)
u.foo = time(0, 9, 8) # raises AttributeError
print(u)
Expected behavior
In the above reproduction, I would expect the u instance to behave as if it'd been created a la Test(**obj).
Environment
ODMantic version: 1.0.2
MongoDB version: 4.7.2
Pydantic infos (output of python -c "import pydantic.utils; print(pydantic.utils.version_info())):
Bug
Attempting to create a model instance using
Model.model_construct
results in__fields_modified__
not being present on the instance, causing AttributeErrors to be raised later when attempting to set attributes on the instance.Current Behavior
Expected behavior
In the above reproduction, I would expect the
u
instance to behave as if it'd been created a laTest(**obj)
.Environment
python -c "import pydantic.utils; print(pydantic.utils.version_info())
):Additional context
Server version shouldn't play into this, as it's reproducible standalone, without talking to mongodb at all.
The text was updated successfully, but these errors were encountered: