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

    • Query Execution
    • QE 2023-04-03, QE 2023-04-17

      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\" }"
      	}
      })
      

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            daniel.gottlieb@mongodb.com Daniel Gottlieb (Inactive)
            Votes:
            3 Vote for this issue
            Watchers:
            20 Start watching this issue

              Created:
              Updated: