[SERVER-3176] autoIndexId not honored in mongo shell's createCollection command Created: 01/Jun/11  Updated: 12/Jul/16  Resolved: 11/Jul/11

Status: Closed
Project: Core Server
Component/s: JavaScript, Shell
Affects Version/s: 1.8.1
Fix Version/s: 1.9.1

Type: Bug Priority: Minor - P4
Reporter: Joachim Assignee: Antoine Girbal
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu, Mac OS X


Issue Links:
Related
related to SERVER-12051 autoIndexId=false allowed on non capp... Closed
Operating System: ALL
Participants:

 Description   

DESCRIPTION

Specifying autoIndexId : false while creating a capped collection from the JS mongo shell does not prevent creation of an index on _id.

STEPS TO REPRODUCE

$ mongo

> use test
> db.createCollection("mycoll",

{size:10000000, autoIndexId:false}

);

{ "ok" : 1 }

> db.mycoll.getIndexes()
[
{
"name" : "id",
"ns" : "test.mycoll",
"key" :

{ "_id" : 1 }

,
"v" : 0
}
]

> db._dbCommand(

{create:"mycoll2", size:10000000, autoIndexId:false}

)

{ "ok" : 1 }

> db.mycoll2.getIndexes()
[ ]

SUGGESTED RESOLUTION

The current createCollection JS function does not copy the autoIndexId parameter from the passed-in opt object. If the parameter is set in opt, also set it in the cmd object.

Current code:
> db.createCollection
function (name, opt) {
var options = opt || {};
var cmd =

{create:name, capped:options.capped, size:options.size, max:options.max}

;
var res = this._dbCommand(cmd);
return res;
}



 Comments   
Comment by auto [ 11/Jul/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: SERVER-3176: autoIndexId not passed if not defined to let DB decide
Branch: master
https://github.com/mongodb/mongo/commit/48342721bb42f23197d447acccd2775d52a219f3

Comment by Antoine Girbal [ 11/Jul/11 ]

resolved with tests

Comment by auto [ 11/Jul/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: SERVER-3176: autoIndexId not honored in mongo shell's createCollection command
Branch: master
https://github.com/mongodb/mongo/commit/d507628f09d04c8091c57c7ad06aedbc30fb4b59

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