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

Duplicate key error message contains incorrect error code after update

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.1.1
    • Component/s: Index Maintenance
    • None
    • Environment:
      Mac OSX 10.7.4
      MongoDB 2.1.1
    • Query
    • ALL

      db.getPrevError() returns an object with an err message that includes the incorrect error code.

      > db.x.drop()
      > db.x.createIndex({ name: 1 }, { unique: 1 })
      > db.x.insert({ name: 'aaron' })
      > db.x.insert({ name: 'another' })
      > db.x.update({ name: 'aaron' }, { $set: { name: 'another' }})
      E11000 duplicate key error index: test.x.$name_1  dup key: { : "another" }
      > db.getPrevError()
      {
      	"err" : "E11000 duplicate key error index: test.x.$name_1  dup key: { : \"another\" }",
      	"code" : 11001,
      	"n" : 0,
      	"nPrev" : 1,
      	"ok" : 1
      }
      

      Expected err message: "E11001 duplicate key error index: test.x.$name_1 dup key: { : \"another\" }"

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            aheckmann Aaron Heckmann
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: