Details
Description
When a user requests a count on a cursor in the shell, all query options unsupported by the count command are ignored, and an incorrect result is delivered to the user. The shell should instead return an error to the user when a count is requested on such a cursor.
Reproduce as follows:
> db.foo.drop()
|
false
|
> db.foo.ensureIndex({a: 1})
|
{
|
"createdCollectionAutomatically" : true, |
"numIndexesBefore" : 1, |
"numIndexesAfter" : 2, |
"ok" : 1 |
}
|
> db.foo.insert({a: 1})
|
WriteResult({ "nInserted" : 1 }) |
> db.foo.insert({a: 2})
|
WriteResult({ "nInserted" : 1 }) |
> db.foo.insert({a: 3})
|
WriteResult({ "nInserted" : 1 }) |
> db.foo.find({}).max({a: 2}).itcount()
|
1
|
> db.foo.find({}).max({a: 2}).count()
|
3 // Unexpected: should return error. |
> db.foo.find({}).min({a: 2}).itcount()
|
2
|
> db.foo.find({}).min({a: 2}).count()
|
3 // Unexpected: should return error. |
> db.foo.find({}).maxScan(1).itcount()
|
1
|
> db.foo.find({}).maxScan(1).count()
|
3 // Unexpected: should return error. |
>
|