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(query): revert breaking changes introduced by #12797 #12999

Merged
merged 3 commits into from
Feb 13, 2023

Conversation

lpizzinidev
Copy link
Contributor

closes #12930

Summary
As a result of this conversation, #12797 introduced breaking changes.
This PR revert them (as well as the fix of #12826) to the previous behavior.

Update queries now do not remove fields set to undefined.

test/query.test.js Show resolved Hide resolved
Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

LGTM

will the original change be re-introduced for 7.0 then?
also what about #12956, should it be merged first or dropped for 6.x?

@hasezoey hasezoey added this to the 6.9.2 milestone Feb 7, 2023
@vkarpov15
Copy link
Collaborator

I don't think we should re-introduce this change in 7.0. I think the original change was generally incorrect, we do not want to convert undefined keys to $unset. That would be potentially risky for anyone that's passing user specified data as updates to Mongoose, assuming that $set removes undefined keys. And I don't think the benefit is quite there. We can consider adding a utility to convert undefined keys to $unset, but I don't think that should be the default.

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.

Undefined values end up failing validation on update
3 participants