[CXX-581] insertion with duplicate _id did not fail, it updated the document instead. Created: 15/Apr/15 Updated: 15/Apr/15 Resolved: 15/Apr/15 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | API |
| Affects Version/s: | legacy-1.0.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Judy Han [X] | Assignee: | Adam Midvidy |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
using the following sample program, if I ran it, modify eventString values and compile and run again, both runs will succeed with data updated. I am expecting the second run to fail with "duplicate key error" . 1 #include "mongo/client/dbclient.h" 15 std::vector<mongo::BSONObj> bulk_data; ; 57 bulk_data.clear(); 69 bulk_data.clear(); catch (...) { 75 std::cout << "Caught an unknown exception during getLastError." << std::endl; 76 } 77 struct timeval end; 92 100 } |
| Comments |
| Comment by Judy Han [X] [ 15/Apr/15 ] |
|
Hi Adam, |
| Comment by Adam Midvidy [ 15/Apr/15 ] |
|
Hi Judy, Yes it is expected behavior that OperationException would be thrown for a duplicate key error. The legacy driver does not have a separate exception type for duplicate key error, although some other drivers do. This is something that is unlikely to change given our desire to keep legacy driver changes limited to bug fixes. Can you show me which documentation you believe this behavior contradicts? And yes, getLastError is thread safe if each thread has its own connection. The server stores getLastError state on a per-connection basis. |
| Comment by Judy Han [X] [ 15/Apr/15 ] |
|
sorry, I said "close" too quickly. Could you reopen it? after removing line 25, for second run, I am expecting something like: instead I got: } Is that expected? It does not match the documenation. Another question I have is: Thanks! |
| Comment by Judy Han [X] [ 15/Apr/15 ] |
|
oops, sorry, my bad. please close the ticket. |
| Comment by Adam Midvidy [ 15/Apr/15 ] |
|
Hi Judy, It appears you are dropping the collection "insert_test.col1" on line 25. As such the behavior you are seeing is expected. Adam |