Insertion of a document with a duplicate key returns a WriteResult such as:
{WriteResult({ "nInserted" : 0, "writeError" : { "code" : 11000, "errmsg" : "E11000 duplicate key error collection: aragorn_development.foo index: id dup key: { : ObjectId('5bda11fdf3b189195ebb0f3a') }" }}
The Error::Parser#122 (parse_code) handles nested error codes for write concern errors, but not writeErrors. The resulting OperationFailure lacks a numeric error code (e.g., 11000).
- duplicates
-
RUBY-1433 OperationError#code not set on duplicate key error
- Closed