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

MongoDB show duplicate key is null?

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.2
    • Component/s: Querying
    • Labels:
      None
    • ALL
    • Hide

      Run this command

       

      db.setup.findAndModify({
       query : {"_id" : ObjectId("5b3c7abbea95705803084cad")},
       update : {$set : { "test" : "xxxx" }},
       upsert : true  })
      
      Show
      Run this command   db.setup.findAndModify({ query : { "_id" : ObjectId( "5b3c7abbea95705803084cad" )}, update : {$set : { "test" : "xxxx" }}, upsert : true   })

      I got the dup key message when I executed this.

      mongos> db.setup.findAndModify({
      ... query : {"_id" : ObjectId("5b3c7abbea95705803084cad")},
      ... update : {$set : { "test" : "xxxx" }},
      ... upsert : true
      ... })
      2018-07-06T10:13:22.749+0000 E QUERY    [thread1] Error: findAndModifyFailed failed: {
          "ok" : 0,
          "errmsg" : "E11000 duplicate key error collection: testdb.setup index: name dup key: { : null }",
          "code" : 11000,
          "codeName" : "DuplicateKey",
          "$clusterTime" : {
              "clusterTime" : Timestamp(1530872002, 603),
              "signature" : {
                  "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                  "keyId" : NumberLong(0)
              }
          },
          "operationTime" : Timestamp(1530872002, 602)
      } :
      _getErrorWithCode@src/mongo/shell/utils.js:25:13
      DBCollection.prototype.findAndModify@src/mongo/shell/collection.js:724:1
      @(shell):1:1
      mongos>
      

            Assignee:
            stephen.steneker@mongodb.com Stennie Steneker (Inactive)
            Reporter:
            jongchana.phuwasate JONGCHANA PHUWASATE
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: