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

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • ALL
    • 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\" }" }})    

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

       

       

            Assignee:
            asya.kamsky@mongodb.com Asya Kamsky
            Reporter:
            vkopyl Vasily Kopyl
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: