@@ -128,12 +128,12 @@ mongoc_bulk_operation_remove (mongoc_bulk_operation_t *bulk, /* IN */
128
128
bulk -> commands .len - 1 );
129
129
if ((last -> type == MONGOC_WRITE_COMMAND_DELETE ) &&
130
130
last -> u .delete .multi ) {
131
- _mongoc_write_command_delete_append (last , & selector , 1 );
131
+ _mongoc_write_command_delete_append (last , selector );
132
132
EXIT ;
133
133
}
134
134
}
135
135
136
- _mongoc_write_command_init_delete (& command , & selector , 1 , true, bulk -> ordered );
136
+ _mongoc_write_command_init_delete (& command , selector , true, bulk -> ordered );
137
137
138
138
_mongoc_array_append_val (& bulk -> commands , command );
139
139
@@ -159,13 +159,12 @@ mongoc_bulk_operation_remove_one (mongoc_bulk_operation_t *bulk, /* IN */
159
159
bulk -> commands .len - 1 );
160
160
if ((last -> type == MONGOC_WRITE_COMMAND_DELETE ) &&
161
161
!last -> u .delete .multi ) {
162
- _mongoc_write_command_delete_append (last , & selector , 1 );
162
+ _mongoc_write_command_delete_append (last , selector );
163
163
EXIT ;
164
164
}
165
165
}
166
166
167
- _mongoc_write_command_init_delete (& command , & selector , 1 , false,
168
- bulk -> ordered );
167
+ _mongoc_write_command_init_delete (& command , selector , false, bulk -> ordered );
169
168
170
169
_mongoc_array_append_val (& bulk -> commands , command );
171
170
@@ -237,6 +236,7 @@ mongoc_bulk_operation_replace_one (mongoc_bulk_operation_t *bulk,
237
236
{
238
237
mongoc_write_command_t command = { 0 };
239
238
size_t err_off ;
239
+ mongoc_write_command_t * last ;
240
240
241
241
bson_return_if_fail (bulk );
242
242
bson_return_if_fail (selector );
@@ -253,6 +253,16 @@ mongoc_bulk_operation_replace_one (mongoc_bulk_operation_t *bulk,
253
253
EXIT ;
254
254
}
255
255
256
+ if (bulk -> commands .len ) {
257
+ last = & _mongoc_array_index (& bulk -> commands ,
258
+ mongoc_write_command_t ,
259
+ bulk -> commands .len - 1 );
260
+ if (last -> type == MONGOC_WRITE_COMMAND_UPDATE ) {
261
+ _mongoc_write_command_update_append (last , selector , document , upsert , false);
262
+ EXIT ;
263
+ }
264
+ }
265
+
256
266
_mongoc_write_command_init_update (& command , selector , document , upsert ,
257
267
false, bulk -> ordered );
258
268
_mongoc_array_append_val (& bulk -> commands , command );
@@ -293,7 +303,7 @@ mongoc_bulk_operation_update (mongoc_bulk_operation_t *bulk,
293
303
mongoc_write_command_t ,
294
304
bulk -> commands .len - 1 );
295
305
if (last -> type == MONGOC_WRITE_COMMAND_UPDATE ) {
296
- _mongoc_write_command_update_append (last , selector , document , multi , upsert );
306
+ _mongoc_write_command_update_append (last , selector , document , upsert , multi );
297
307
EXIT ;
298
308
}
299
309
}
@@ -313,6 +323,7 @@ mongoc_bulk_operation_update_one (mongoc_bulk_operation_t *bulk,
313
323
{
314
324
mongoc_write_command_t command = { 0 };
315
325
bson_iter_t iter ;
326
+ mongoc_write_command_t * last ;
316
327
317
328
bson_return_if_fail (bulk );
318
329
bson_return_if_fail (selector );
@@ -330,6 +341,16 @@ mongoc_bulk_operation_update_one (mongoc_bulk_operation_t *bulk,
330
341
}
331
342
}
332
343
344
+ if (bulk -> commands .len ) {
345
+ last = & _mongoc_array_index (& bulk -> commands ,
346
+ mongoc_write_command_t ,
347
+ bulk -> commands .len - 1 );
348
+ if (last -> type == MONGOC_WRITE_COMMAND_UPDATE ) {
349
+ _mongoc_write_command_update_append (last , selector , document , upsert , false);
350
+ EXIT ;
351
+ }
352
+ }
353
+
333
354
_mongoc_write_command_init_update (& command , selector , document , upsert ,
334
355
false, bulk -> ordered );
335
356
_mongoc_array_append_val (& bulk -> commands , command );
0 commit comments