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): remove unnecessary check for atomic operators in findOneAndReplace() #13678

Merged
merged 13 commits into from Aug 1, 2023

Conversation

vkarpov15
Copy link
Collaborator

Summary

This error check is both brittle and unnecessary. Unnecessary because the MongoDB driver already throws MongoInvalidArgumentError: Replacement document must not contain atomic operators. Brittle because it doesn't take into account chaining, like .findOneAndReplace().set({ $push: 'foo' }). I also don't like how this check uses vanilla Error rather than MongooseError.

Examples

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

LGTM, thanks. 👍

@vkarpov15 vkarpov15 changed the base branch from master to 7.5 August 1, 2023 14:30
@vkarpov15 vkarpov15 added this to the 7.5 milestone Aug 1, 2023
@vkarpov15
Copy link
Collaborator Author

Merging into 7.5 👍

@vkarpov15 vkarpov15 merged commit 7ddb381 into 7.5 Aug 1, 2023
34 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/remove-unnecessary-error branch August 5, 2023 20:36
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.

None yet

3 participants