Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1719

v:1 option ignored by createIndex which still creates a v:2 index

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • No version
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      OS:
      node.js / npm versions:
      Additional info:
    • Not Needed
    • Developer Tools

      Steps to Reproduce

      In mongosh run the following commands:

      1. db.collection.createIndex({a: 1}, {v: 1})
      2. db.collection.getIndexes()

      Expected Results

      [
        { v: 2, key: { _id: 1 }, name: '_id_' },
        { v: 1, key: { a: 1 }, name: 'a_1' }
      ]

      Actual Results

      [
        { v: 2, key: { _id: 1 }, name: '_id_' },
        { v: 2, key: { a: 1 }, name: 'a_1' }
      ]

      Additional Notes

      The mongo shell built from "ninja install-devcore" still behaves as expected.

      (python3-venv) ubuntu@ip-10-122-6-82:~/mongo$ ./build/install/bin/mongo
      MongoDB shell version v8.0.0-alpha-779-g2085354
      connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
      Implicit session: session { "id" : UUID("e94fcd56-dd45-42d8-be36-5e10d0a3c9aa") }
      MongoDB server version: 8.0.0-alpha-779-g2085354
      ================
      Warning: the "mongo" shell has been superseded by "mongosh",
      which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
      an upcoming release.
      
      > db.collection.createIndex({a: 1}, {v: 1})
      {
          "numIndexesBefore" : 1,
          "numIndexesAfter" : 2,
          "createdCollectionAutomatically" : false,
          "ok" : 1
      }
      > db.collection.getIndexes()
      [
          {
              "v" : 2,
              "key" : {
                  "_id" : 1
              },
              "name" : "_id_"
          },
          {
              "v" : 1,
              "key" : {
                  "a" : 1
              },
              "name" : "a_1"
          }
      ]

            Assignee:
            Unassigned Unassigned
            Reporter:
            wei.hu@mongodb.com Wei Hu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: