[GODRIVER-707] method/operation to determine if a write error is a duplicate key error Created: 15/Dec/18 Updated: 27/Oct/23 Resolved: 10/Jan/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 0.3.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Sam Kleinman (Inactive) | Assignee: | Divjot Arora (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | evg | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
this might just be a usability consideration, but I can't find anyway to determine or check if an error from an insert or an upsert is a duplicate key error, without (presumably, parsing the string form of the error, which looks to be derived from what the server transmits. |
| Comments |
| Comment by Divjot Arora (Inactive) [ 10/Jan/19 ] |
|
Duplicate key errors can be captured by casting the error from an InsertOne or InsertMany to mongo.WriteErrors or mongo.BulkWriteException, respectively. |
| Comment by Ian Whalen (Inactive) [ 07/Jan/19 ] |
|
Probably do the same thing we did for the topology disconnected error and find all of the places we used it and replace command.Error with mongo.CommandError. |