Skip to content

Commit

Permalink
0.11.1 - Fix deepcopy issues (#695)
Browse files Browse the repository at this point in the history
* fix deepcopy issues

* bump version, add release changelog
  • Loading branch information
collerek authored Jun 8, 2022
1 parent d2c4dca commit 4d76934
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 127 deletions.
6 changes: 6 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.11.1

## 🐛 Fixes

* Fix deepcopy issues introduced in pydantic 1.9 [#685](https://github.com/collerek/ormar/issues/685)

# 0.11.0

## ✨ Breaking Changes
Expand Down
16 changes: 16 additions & 0 deletions ormar/models/newbasemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,22 @@ def __same__(self, other: "NewBaseModel") -> bool:
)
)

def _copy_and_set_values(
self: "NewBaseModel", values: "DictStrAny", fields_set: "SetStr", *, deep: bool
) -> "NewBaseModel":
"""
Overwrite related models values with dict representation to avoid infinite
recursion through related fields.
"""
self_dict = values
self_dict.update(self.dict())
return cast(
"NewBaseModel",
super()._copy_and_set_values(
values=self_dict, fields_set=fields_set, deep=deep
),
)

@classmethod
def get_name(cls, lower: bool = True) -> str:
"""
Expand Down
Loading

0 comments on commit 4d76934

Please sign in to comment.