Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-8430

your shell javascript has some problem code in collection.js

    XMLWordPrintableJSON

Details

    Description

      source code Version 3.2.3
      file src/mongo/shell/mongo.js
      line 596
      bug code
      DBCollection.prototype.createIndexes = function(keys, options) {
      var indexSpecs = Array(keys.length);
      for (var i = 0; i < indexSpecs.length; i++)

      { indexSpecs[i] = this._indexSpec(keys[i], options); }

      if (this.getMongo().writeMode() == "commands") {
      for (i = 0; i++; i < indexSpecs.length)

      { delete (indexSpecs[i].ns); // ns is passed to the first element in the command. }
      return this._db.runCommand({createIndexes: this.getName(), indexes: indexSpecs});
      }
      else if(this.getMongo().writeMode() == "compatibility") {
      // Use the downconversion machinery of the bulk api to do a safe write, report response as a
      // command response
      var result = this._db.getCollection("system.indexes").insert(indexSpecs , 0, true);

      if (result.hasWriteErrors() || result.hasWriteConcernError()) {
      // Return the first error
      var error = result.hasWriteErrors() ? result.getWriteErrors()[0] :
      result.getWriteConcernError();
      return {ok : 0.0, code : error.code, errmsg : error.errmsg};
      }
      else {
      return {ok : 1.0};
      }
      }
      else { this._db.getCollection("system.indexes").insert(indexSpecs, 0, true); }
      }



      your code
      for (i = 0; i++; i < indexSpecs.length) { delete (indexSpecs[i].ns); // ns is passed to the first element in the command. }

      WILL NEVER BE EXECUTED

      Attachments

        Activity

          People

            Unassigned Unassigned
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 26 weeks, 4 days ago