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

Allow single-write operations to throw a DuplicateKeyException

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.0.2
    • Component/s: None
    • None

      From this comment:

      A DuplicateKeyException has no logical application in the new driver, as all writes are executed through MongoDB\Driver\Manager::executeBulkWrite(). The thrown BulkWriteException might include any number of errors, which you'll need to infer from the result object. For the benefit of logging, we do concatenate all error messages into the BulkWriteException's message.

      Consider adding such an exception for the library's single-write methods. When those operations execute a single-item BulkWrite, we'd need to catch the BulkWriteException and transform it into a DuplicateKeyException before re-throwing.

      This may be a list of error codes to check for: https://github.com/mongodb/mongo-php-driver-legacy/blob/d4ce6992164893d185e9d1538c48857479d1554e/cursor_shared.c#L540

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: