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

InsertMany behaves as expected for validation errors while ordered op… #5072

Merged
merged 4 commits into from
Mar 15, 2017

Conversation

sjorssnoeren
Copy link
Contributor

@sjorssnoeren sjorssnoeren commented Mar 14, 2017

Summary

The native mongodb driver documents functionality for an option called: 'ordered'. It's documentation is as follows: If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. I expected this to work with mongoose as well, as it is documented. However this is only true for failing unique constraint errors. I've made little modifications to make it work for all validation errors.

Test plan

Added an extra unit test for making sure the behavior of validation errors is identical to the one of constraint errors

Notice

This is one of my very first pull-requests, if I went too far without discussion or if there are other concerns that need taken care of please let me know.

…tion is disabled

InsertMany already did use the ordered option for unique constraint
errors but didn’t for validation errors. As expected insertMany should
behave likewise for validation errors.
@sjorssnoeren sjorssnoeren reopened this Mar 14, 2017
@vkarpov15 vkarpov15 added this to the 4.9.1 milestone Mar 15, 2017
@vkarpov15
Copy link
Collaborator

This is great work, thank you very much for your contribution, will be released with 4.9.1, ETA Sunday March 19 👍 🚀

@vkarpov15 vkarpov15 merged commit 91866a8 into Automattic:master Mar 15, 2017
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.

2 participants