[CDRIVER-1060] Bulk write updates require $set, but regular updates do not Created: 05/Jan/16  Updated: 05/Jan/16  Resolved: 05/Jan/16

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.3.1

Type: Bug Priority: Major - P3
Reporter: Tess Avitabile (Inactive) Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CXX-797 Updating entire document without oper... Closed

 Description   

mongoc_bulk_operation_update (bulk, BCON_NEW ("a", BCON_INT32 (1)), BCON_NEW ("a", BCON_INT32 (2)), false);
 
mongoc_bulk_operation_execute (bulk, &reply, &error);

produces the error

WARNING:       mongoc: mongoc_bulk_operation_update(): update only works with $ operators.
Error: Cannot do an empty bulk write

However, mongoc_collection_update allows updating without $set.



 Comments   
Comment by Hannes Magnusson [ 05/Jan/16 ]

This behaviour originates from the CRUD spec - Update vs. Replace Validation

The idea is to prevent people from accidentally replacing an entire object.

For normal updates use mongoc_bulk_operation_update and to replace entire object use mongoc_bulk_operation_replace.
See also http://api.mongodb.org/c/current/mongoc_bulk_operation_update.html

Generated at Wed Feb 07 21:11:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.