Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-3176

autoIndexId not honored in mongo shell's createCollection command

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.9.1
    • Affects Version/s: 1.8.1
    • Component/s: JavaScript, Shell
    • Labels:
      None
    • Environment:
      Ubuntu, Mac OS X
    • ALL

      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;
      }

            Assignee:
            antoine Antoine Girbal
            Reporter:
            joachim@friend.ly Joachim
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: