Ensure that users can distinguish duplicate key write errors

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I propose we introduce a new DuplicateKeyException if we can detect the relevant error code in a BulkWriteException thrown from Server::executeBulkWrite(). We should be able to do this for non-ambiguous cases, such as single-statement writes (e.g. insertOne, updateOne).

      It may be feasible for multi-statement writes (e.g. insertMany, bulkWrite) if all errors in the BulkWriteException can be classified as a DuplicateKeyException. If there are various write errors in the bulk write exception (possible if ordered is false), we should leave the exception as-is so that users can make sense of it. Before handling the multi-statement case, let's consult with other drivers to see if there is prior art.

            Assignee:
            Unassigned
            Reporter:
            Jeremy Mikola
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: