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

Bug fix: Model#save should pass numberAffected as 0 when nothing changed #3195

Merged
merged 2 commits into from Jul 26, 2015
Merged

Conversation

burtonjc
Copy link
Contributor

Currently, calling Model#save on an unchanged document results in numberAffected in the callback being set to the document itself. According to the docs, numberAffected should always be 0 or 1 (never a document):

... numberAffected which will be 1 when the document was found and updated in the database, otherwise 0.

In mongoose v3.x this used to work as expected, it was only after upgrading to v4 that we noticed this.

@burtonjc burtonjc changed the title Model#save should pass numberAffected as 0 when nothing changed Bug fix: Model#save should pass numberAffected as 0 when nothing changed Jul 24, 2015
@burtonjc burtonjc closed this Jul 24, 2015
@burtonjc burtonjc reopened this Jul 24, 2015
@burtonjc burtonjc closed this Jul 24, 2015
@burtonjc burtonjc reopened this Jul 24, 2015
@vkarpov15 vkarpov15 added this to the 4.0.9 milestone Jul 24, 2015
@vkarpov15
Copy link
Collaborator

Thanks!

@burtonjc burtonjc closed this Jul 24, 2015
@burtonjc
Copy link
Contributor Author

@vkarpov15 I was fixing merge conflicts for this PR and somehow closed it, sorry about that. Reopening.

@burtonjc burtonjc reopened this Jul 24, 2015
vkarpov15 added a commit that referenced this pull request Jul 26, 2015
Bug fix: Model#save should pass numberAffected as 0 when nothing changed
@vkarpov15 vkarpov15 merged commit 97424bb into Automattic:master Jul 26, 2015
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

2 participants