Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-225

Ensure that users can distinguish duplicate key write errors

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: 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 Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: