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(document): save newly set defaults underneath single nested subdocuments #13002

Merged
merged 1 commit into from
Feb 6, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #12905

Summary

If applyDefaults() creates a default underneath a single nested subdocument when loading from MongoDB, a subsequent save() won't save that default. This is a quick fix that handles that particular case. It won't handle nested subdocuments, or subdocuments underneath arrays, because that's proven to be a bit trickier. However, this PR should be enough to unblock OP from #12905 with minimal risk, and we can improve change tracking in this case later.

Examples

Copy link
Collaborator

@IslandRhythms IslandRhythms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vkarpov15 vkarpov15 merged commit 1643461 into master Feb 6, 2023
@hasezoey hasezoey deleted the vkarpov15/gh-12905 branch February 7, 2023 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

default values are not saved when added to existing documents, when schema is
2 participants