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

E11000 duplicate key error cannot be understood when using Swedish collation

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.0.2, 6.3.0-rc2
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • Hide

      When using collation sv:

       

      use testDb;
      db.testCollection.drop();
      db.createCollection("testCollection", { collation: { locale: "sv" }});
      db.testCollection.createIndex({ "key": 1 }, { unique: true } );
      db.testCollection.insertOne({"key":"uniquevalue"});
      db.testCollection.insertOne({"key":"uniquevalue"});

      Gives error message with some sort of hex value:
      MongoServerError: E11000 duplicate key error collection: testDb.testCollection index: key_1 collation: { locale: "sv", caseLevel: false, caseFirst: "off", strength: 3, numericOrdering: false, alternate: "non-ignorable", maxVariable: "punct", normalization: false, backwards: false, version: "57.1" } dup key: { key: "0x51433949513153293f5131010f010f" }

       

      But when using default collation it give me an understandable error message without the hex value:

      use testDb;
      db.testCollection.drop();
      db.createCollection("testCollection");
      db.testCollection.createIndex({ "key": 1 }, { unique: true } );
      db.testCollection.insertOne({"key":"uniquevalue"});
      db.testCollection.insertOne({"key":"uniquevalue"});

      Gives error message that is easy to understand:
      MongoServerError: E11000 duplicate key error collection: testDb.testCollection index: key_1 dup key: { key: "uniquevalue" }

       

      Show
      When using collation sv:   use testDb; db.testCollection.drop(); db.createCollection( "testCollection" , { collation: { locale: "sv" }}); db.testCollection.createIndex({ "key" : 1 }, { unique: true } ); db.testCollection.insertOne({ "key" : "uniquevalue" }); db.testCollection.insertOne({ "key" : "uniquevalue" }); Gives error message with some sort of hex value: MongoServerError: E11000 duplicate key error collection: testDb.testCollection index: key_1 collation: { locale: "sv", caseLevel: false, caseFirst: "off", strength: 3, numericOrdering: false, alternate: "non-ignorable", maxVariable: "punct", normalization: false, backwards: false, version: "57.1" } dup key: { key: " 0x51433949513153293f5131010f010f " }   But when using default collation it give me an understandable error message without the hex value: use testDb; db.testCollection.drop(); db.createCollection( "testCollection" ); db.testCollection.createIndex({ "key" : 1 }, { unique: true } ); db.testCollection.insertOne({ "key" : "uniquevalue" }); db.testCollection.insertOne({ "key" : "uniquevalue" }); Gives error message that is easy to understand: MongoServerError: E11000 duplicate key error collection: testDb.testCollection index: key_1 dup key: { key: " uniquevalue " }  

      When you have a collection with Swedish collation and a unique index and you try to insert two documents that trigger a duplicate key exception, the error message contains information that cannot be understood and linked to which document is causing the error.

       

      If you have a collection without specified collation, you get an error message where you can understand which document is causing the duplicate key exception.

      Is it possible to solve so that the error message for collections that do not have a default collation becomes easier to understand, so that you know which document is causing the error?

      Or can I interpret the hex code myself so that it becomes readable for my users?
      I can't match it against any UTF character table.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            daniel@prodev.se Daniel Moqvist
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: