[SERVER-6634] Count accepts negative skip values Created: 28/Jul/12  Updated: 11/Jul/16  Resolved: 25/Sep/12

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.0.6, 2.2.0-rc0
Fix Version/s: 2.3.0

Type: Bug Priority: Minor - P4
Reporter: Kevin Matulef Assignee: Shaun Verch
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Major Change
Operating System: ALL
Participants:

 Description   

Count command happily accepts negative skip values, and subtracts them from the count result:

> db.bar.drop()
> for(i=0; i < 10; i++){db.bar.insert({a : i})}
> db.bar.find().count(true)
10
> db.bar.find().skip(-5).count(true)
15

It should probably throw an error if you give it a negative skip (like it does if you leave out the "count" part)



 Comments   
Comment by Shaun Verch [ 25/Sep/12 ]

Command now fails when skip is passed a negative number or a non number value.

Comment by auto [ 25/Sep/12 ]

Author:

{u'date': u'2012-08-27T15:22:12-07:00', u'email': u'shaun.verch@10gen.com', u'name': u'Shaun Verch'}

Message: SERVER-6634 Handle negative and invalid skip values in count command
Branch: master
https://github.com/mongodb/mongo/commit/9424ec487448c6b8ef79ac1eb63e515fa0ed09d2

Generated at Thu Feb 08 03:12:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.