tl;dr: In mongo-java-driver 3.4.2 (and higher), calling BulkWriteOperation.execute() throws a BulkWriteException when some of the writes fail. fongo was throwing DuplicateKeyException for the same operation. This PR brings fongo in line with that behavior.
This feels weird to me because it means I have to throw away data when I translate a com.mongodb.BulkWriteError to a com.mongodb.bulk.BulkWriteError, but it's what the unit tests are looking for and I'm assuming those unit tests are validating how mongo behaves, so I maintained that behavior instead of modifying the test.
Fixes https://github.com/fakemongo/fongo/issues/328
tl;dr: In mongo-java-driver 3.4.2 (and higher), calling
BulkWriteOperation.execute()
throws aBulkWriteException
when some of the writes fail. fongo was throwingDuplicateKeyException
for the same operation. This PR brings fongo in line with that behavior.I left a comment in translateWriteErrorsToNew: the tests in
FongoInsertManyTest
, such asshould_throw_MongoBulkWriteException_if_middle_document_is_duplicated_and_ordered
, specifically check for an empty document in thedetails
field of theBulkWriteError
.This feels weird to me because it means I have to throw away data when I translate a
com.mongodb.BulkWriteError
to acom.mongodb.bulk.BulkWriteError
, but it's what the unit tests are looking for and I'm assuming those unit tests are validating how mongo behaves, so I maintained that behavior instead of modifying the test.