Skip to content

Modified limitRequest to allow negative limits to pass through to Mongo.... #561

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

Merged
merged 1 commit into from
Mar 23, 2012

Conversation

madtimber
Copy link
Contributor

... Appropriate tests added.

@christkv
Copy link
Contributor

can you explain me what situation requires a negative limit ?

@madtimber
Copy link
Contributor Author

Well, I there's not many situations that require a negative limit, but I submitted the change for two reasons:

  1. Consistency. Your driver handles -1 just fine (sends Mongo a -1 and it in turns changes it to a 1) so I would think it should handle other negative numbers in the same manner.
  2. Mongo handles negative limits just fine. It seems to take the absolute value of any limit coming in, so why not allow it.

The way I actually found this 'bug' is through some of my unit tests I was writing for my application. I had two test cases that were sending in negative numbers (-1 and -5) and the -1 limit was returning one document while the -5 was returning ALL documents. So theres a bit of unintended behavior there, I think.

So since Mongo handles negative limits just fine, and you allow -1 to go through, I think any negative limit should be allowed to go through and let Mongo handle it the way it wants to.

Thoughts?

@madtimber
Copy link
Contributor Author

@ehazlett, any thoughts? (he was pairing with me on this patch)

@ehazlett
Copy link

Nope. My thoughts echo yours.

@christkv christkv merged commit 33b0efe into mongodb:master Mar 23, 2012
@dandv
Copy link
Contributor

dandv commented Mar 2, 2014

Speaking of negative limits, any chance to expedite documenting them?

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.

4 participants