diff --git a/odmantic/model.py b/odmantic/model.py index 08308f29..13fdeb02 100644 --- a/odmantic/model.py +++ b/odmantic/model.py @@ -609,7 +609,7 @@ def _post_copy_update(self: BaseT) -> None: Set them as if they were modified to make sure they are saved in the database. """ - object.__setattr__(self, "__fields_modified__", set(self.model_fields)) + object.__setattr__(self, "__fields_modified__", set(self.__class__.model_fields)) for field_name, field in self.__odm_fields__.items(): if isinstance(field, ODMEmbedded): value = getattr(self, field_name) @@ -1006,7 +1006,7 @@ def model_update( ) -> None: is_primary_field_in_patch = ( isinstance(patch_object, BaseModel) - and self.__primary_field__ in patch_object.model_fields + and self.__primary_field__ in patch_object.__class__.model_fields ) or (isinstance(patch_object, dict) and self.__primary_field__ in patch_object) if is_primary_field_in_patch: if (