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

Unique key violation for index with a non-simple collation has unclear error message

    XMLWordPrintable

    Details

    • Case:

      Description

      db.numbers.ensureIndex({text: 1}, {unique: true, collation: {locale: "en", numericOrdering: true}})
      db.numbers.insert({text: "10"})
      db.numbers.insert({text: "10"})
      

      Gives an output of:

      WriteResult({
      	"nInserted" : 0,
      	"writeError" : {
      		"code" : 11000,
      		"errmsg" : "E11000 duplicate key error index: test.numbers.$text_1 dup key: { : \"\u000f\f\u0001\u0005\u0001\u0005\" }"
      	}
      })
      

      Whereas values not transformed by ICU provide a readable key:

      WriteResult({
      	"nInserted" : 0,
      	"writeError" : {
      		"code" : 11000,
      		"errmsg" : "E11000 duplicate key error index: test.strings.$text_1 dup key: { : \"10\" }"
      	}
      })
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: