[SERVER-22040] Shell should return error when user requests count on non-countable cursor Created: 31/Dec/15  Updated: 06/Dec/22  Resolved: 03/Dec/21

Status: Closed
Project: Core Server
Component/s: Querying, Shell
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: J Rassi Assignee: Backlog - Server Tooling and Methods (STM) (Inactive)
Resolution: Won't Fix Votes: 0
Labels: move-stm
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Server Tooling & Methods
Operating System: ALL
Participants:

 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.
>



 Comments   
Comment by Brooke Miller [ 03/Dec/21 ]

STM doesn't have bandwidth to pick this up, so we're closing as won't fix. However, if other teams have capacity and would like to pursue this, please feel free to pick this up.

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