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

[MONGOSH] Incomplete output from collMod operation

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.6.1
    • Affects Version/s: None
    • Component/s: CLI Module
    • None
    • 3
    • Not Needed
    • Iteration Grouper, Iteration Herring, Iteration Isopod, Iteration Jellyfish, Iteration Lobster, Iteration Porpoise

      (From edited Slack discussion)

      There's a difference between the old and new shells.

      collMod should return a CannotConvertIndexToUnique error with a list of conflicting documents.

      Test collection:
      db.apples.insertMany( [

      { type: "Delicious", quantity: 12 }

      ,

      { type: "Macintosh", quantity: 13 }

      ,

      { type: "Delicious", quantity: 13 }

      ,

      { type: "Fuji", quantity: 15 }

      ,

      { type: "Washington", quantity: 10 }

      ,
      ] )

      test> db.runCommand( {
      collMod: "apples",
      index: {
      keyPattern:

      { type: 1 }

      ,
      unique: true
      }
      } )

      mongosh response:
      MongoServerError: Cannot convert the index to unique. Please resolve conflicting documents before running collMod again.

      mongo shell response
      {
      "ok" : 0,
      "errmsg" : "Cannot convert the index to unique. Please resolve conflicting documents before running collMod again.",
      "code" : 359,
      "codeName" : "CannotConvertIndexToUnique",
      "violations" : [

      { "ids" : [ ObjectId("62a2015777e2d47c4da33146"), ObjectId("62a2015777e2d47c4da33148") ] }

      ]
      }

            Assignee:
            sergey.petushkov@mongodb.com Sergey Petushkov
            Reporter:
            dave.cuthbert@mongodb.com Dave Cuthbert (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: