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

Fix embedded models parsing with key_name #262

Merged
merged 4 commits into from
Sep 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update model.py
Fix bug (issue #260): when using key_name in EmbeddedModel's fields, insertion work properly but resuming document fails
  • Loading branch information
iXB3 authored and art049 committed Sep 8, 2022
commit 2605e714bc59ac8bb1e4cd1f4ea61c3d06474983
7 changes: 7 additions & 0 deletions odmantic/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,13 @@ def _parse_doc_to_obj(
)
)
else:
# iXB3 changes: recursively parse embedded document to dict with model keys
if isinstance(field, ODMEmbedded):
sub_errors, value = field.model._parse_doc_to_obj(
value, base_loc=base_loc + (field_name,)
)
errors.extend(sub_errors)
# end iXB3 changes
obj[field_name] = value

if cls.Config.extra == "allow":
Expand Down