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

Replace bad not found check in Update. #113

Closed
wants to merge 1 commit into from
Closed

Replace bad not found check in Update. #113

wants to merge 1 commit into from

Conversation

tcard
Copy link

@tcard tcard commented Jun 3, 2015

Update was assuming that, if no document was updated, the selector query wasn't matching anything, thus returning ErrNotFound. That's wrong, because it can happen that the selector matches but then the new updated value is jus the same as the old one, in which case nModified is 0 even if the query is successful.

Now LastError has a Found method that returns true if result.N is greater than zero. Update checks that method instead of UpdatedExisting.

I haven't added a test nor run the existing ones because apparently they need a quite complex previous setup in your machine. Sorry for that.

`Update` was assuming that, if no document was updated, the selector query wasn't matching anything, thus returning `ErrNotFound`. That's wrong, because it can happen that the selector matches but then the new updated value is jus the same as the old one, in which case `nModified` is 0 even if the query is successful.

Now `LastError` has a `Found` method that returns true if `result.N` is greater than zero. `Update` checks that method instead of `UpdatedExisting`.

I haven't added a test nor run the existing ones because apparently they need a quite complex previous setup in your machine. Sorry for that.
@niemeyer
Copy link
Contributor

niemeyer commented Jun 3, 2015

Thanks for the contribution. Let's please avoid adding a new method, as it's unrelated to the bug being fixed and we don't need to agree on it right now (LastError.Found is misleading, for example). Then, we do need tests for it. You can start servers in your machine by running "make startdb" before running the test suite. If you don't want to do this, please just open an issue including a snippet that demonstrates the bug and I'll fix it locally.

@niemeyer
Copy link
Contributor

niemeyer commented Jun 3, 2015

Also, please mention which server versions you are testing this under.

@niemeyer niemeyer closed this in 8466119 Jun 3, 2015
@niemeyer
Copy link
Contributor

niemeyer commented Jun 3, 2015

Sorry, this cannot wait. I've fixed it and will tag a new release shortly.

@niemeyer
Copy link
Contributor

niemeyer commented Jun 3, 2015

This is out.

@tcard
Copy link
Author

tcard commented Jun 4, 2015

I wasn't able to make the changes in time. Thanks for taking care of it.

This pull request was closed.
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