|
When we return DuplicateKey errors on clustered collections, we do not pass the user-provided collation, and instead, use no collation (the default).
This can result in parsing errors or returning incorrect values when duplicate keys are encountered and a collation is used.
For example
test> db.createCollection('c', {clusteredIndex: {key: {_id: 1}, unique:true}, collation: {locale: "en_US"}})
|
{ ok: 1 }
|
test> db.c.insert({_id: "hello"})
|
{ acknowledged: true, insertedIds: { '0': 'hello' } }
|
test> db.c.insert({_id: "hello"})
|
Uncaught:
|
MongoBulkWriteError: E11000 duplicate key error collection: test.c dup key: { _id: "71??E " }
|
Result: BulkWriteResult {
|
result: {
|
ok: 1,
|
writeErrors: [
|
WriteError {
|
err: {
|
index: 0,
|
code: 11000,
|
errmsg: 'E11000 duplicate key error collection: test.c dup key: { _id: "71??E\x01\t\x01\t" }',
|
errInfo: undefined,
|
op: { _id: 'hello' }
|
}
|
}
|
|