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

Dup key value is not readable in error message when unique index is created with collation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Indexing
    • Labels:
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      db.createCollection('people')
      db.people.insert({userName: 'Bob'})
      db.people.insert({userName: 'Sally'})

      db.people.createIndex({userName: 1}, {unique: true, collation: { locale: 'en', strength: 2}})

      db.people.insert({userName: 'BOB'})

       

      The last method throws the error:

      WriteResult({WriteResult({ "nInserted" : 0, "writeError" : { "code" : 11000, "errmsg" : "E11000 duplicate key error collection: members.people index: userName_1 dup key: { : \"E\u0001\u0007\" }" }})

       

      Expected:

      WriteResult({WriteResult({ "nInserted" : 0, "writeError" : { "code" : 11000, "errmsg" : "E11000 duplicate key error collection: members.people index: userName_1 dup key: { : \"BOB\" }" }})

       

       

      Show
      db.createCollection('people') db.people.insert({userName: 'Bob'}) db.people.insert({userName: 'Sally'}) db.people.createIndex({userName: 1}, {unique: true, collation: { locale: 'en', strength: 2}}) db.people.insert({userName: 'BOB'})   The last method throws the error: WriteResult({WriteResult({ "nInserted" : 0, "writeError" : { "code" : 11000, "errmsg" : "E11000 duplicate key error collection: members.people index: userName_1 dup key: { : \" E \u0001\u0007\" }" }})   Expected: WriteResult({WriteResult({ "nInserted" : 0, "writeError" : { "code" : 11000, "errmsg" : "E11000 duplicate key error collection: members.people index: userName_1 dup key: { : \"BOB\" }" }})    

      Description

      Duplicate key error message reports the key value in unreadable form. This occurs if an index created with collation. 

       

       

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: