Skip to content

Commit be29c4f

Browse files
author
Christian Hergert
committed
write-command: if writeErrors is non-empty, mark result as failed.
This will ensure we do not continue processing in the ordered bulk API case. Otherwise, we could accidentially continue in the case of failure.
1 parent 8dd1594 commit be29c4f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/mongoc/mongoc-write-command.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ _mongoc_write_result_merge (mongoc_write_result_t *result, /* IN */
937937
{
938938
const bson_value_t *value;
939939
bson_iter_t iter;
940+
bson_iter_t citer;
940941
int32_t n_upserted = 0;
941942
int32_t affected = 0;
942943

@@ -950,6 +951,13 @@ _mongoc_write_result_merge (mongoc_write_result_t *result, /* IN */
950951
affected = bson_iter_int32 (&iter);
951952
}
952953

954+
if (bson_iter_init_find (&iter, reply, "writeErrors") &&
955+
BSON_ITER_HOLDS_ARRAY (&iter) &&
956+
bson_iter_recurse (&iter, &citer) &&
957+
bson_iter_next (&citer)) {
958+
result->failed = true;
959+
}
960+
953961
switch (command->type) {
954962
case MONGOC_WRITE_COMMAND_INSERT:
955963
result->nInserted += affected;

0 commit comments

Comments
 (0)