Details
Description
Create command should reject incorrect types for known options. It's easy to accidentally provide the wrong types for a "create" option, like providing a string for "max":
MongoDB Enterprise > db.createCollection("test", {capped:true, size:10, max:"10"})
|
{ "ok" : 1 }
|
MongoDB Enterprise > db.getCollectionInfos()
|
[
|
{
|
"name" : "test",
|
"type" : "collection",
|
"options" : {
|
"capped" : true,
|
"size" : 256
|
},
|
...
|
Or forgetting the "capped" option but including "size" and "max":
MongoDB Enterprise > db.createCollection("test2", {size:10, max:10})
|
{ "ok" : 1 }
|
MongoDB Enterprise > db.getCollectionInfos()
|
[
|
{
|
"name" : "test2",
|
"type" : "collection",
|
"options" : {
|
|
},
|
...
|
In both of these cases, the server silently ignores some of the options and creates a collection that, almost certainly, is not what the user wanted. I think it would be an improvement for the "create" command to return an InvalidOptions error instead.
This is semi-related to SERVER-25459 (Create command should reject unknown options) and SERVER-16069 (Input validation on the arguments to createCollection).
Attachments
Issue Links
- is depended on by
-
SERVER-40345 Remove the 'temp' field from the 'create' command
-
- Closed
-
- is related to
-
PYTHON-1728 What is the proper way to create a capped collection with "max" and "size"?
-
- Closed
-
- related to
-
SERVER-25459 Create command should reject unknown options
-
- Closed
-