fakemongo / fongo

faked out in-memory mongo for java
Apache License 2.0
523 stars 155 forks source link

BulkWriteOperation.execute() now throws BulkWriteException #334

Closed MustafaHaddara closed 6 years ago

MustafaHaddara commented 6 years ago

Fixes https://github.com/fakemongo/fongo/issues/328

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.

I left a comment in translateWriteErrorsToNew: the tests in FongoInsertManyTest, such as should_throw_MongoBulkWriteException_if_middle_document_is_duplicated_and_ordered, specifically check for an empty document in the details field of the BulkWriteError.

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.

boweihan commented 6 years ago

What's the status on this?

twillouer commented 6 years ago

thanks !