-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: 2.6.2
-
Component/s: Write Ops
-
Fully Compatible
-
ALL
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
According to the write command spec, 1 and 0 are the only permissible values for the delete command's "limit" option. Unexpectedly, the server treats any value other than 1 as "no limit":
> db.foo.drop(); true > db.runCommand({insert:"foo",documents:[{x:1},{x:2},{x:3}]}) { "ok" : 1, "n" : 3 } > db.foo.find() { "_id" : ObjectId("53a0971a3d971a72e86ca57f"), "x" : 1 } { "_id" : ObjectId("53a0971a3d971a72e86ca580"), "x" : 2 } { "_id" : ObjectId("53a0971a3d971a72e86ca581"), "x" : 3 } > db.runCommand({delete:"foo",deletes:[{q:{},limit:2}]}) { "ok" : 1, "n" : 3 } > db.foo.find() >
Until the server does support deletion limits, it would be safer to return a write error in this case (similar to what is currently done if the "limit" option is missing entirely).