[CDRIVER-2273] Do not include default write concern in insert, update, and delete commands Created: 11/Sep/17  Updated: 28/Oct/23  Resolved: 23/Nov/17

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.7.0
Fix Version/s: 1.9.0

Type: Improvement Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Jeremy Mikola
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by CDRIVER-2383 Write commands can send empty write c... Closed
Related
related to CDRIVER-2274 _mongoc_write_command_init() may free... Closed
is related to PHPC-976 Create isDefault() method for read an... Closed
is related to PHPLIB-261 Omit default read and write concern f... Closed

 Description   

3e34af3 added logic to omit specifying default read and write concerns (i.e. an empty document value) in command documents. However, the code path for insert, update, and delete is still prone to adding a "writeConcern" key with an empty document value to the command document.

redbeard0531 confirmed that mongod versions going back to 2.6 treat an empty document for "writeConcern" as if the option had never been specified, but I think it would be preferable if libmongoc was consistent here and omitted the option on its own.

This came up while some users were analyzing logs for the PHP driver (see: mongodb/mongo-php-library#326) and did not expect to see a "writeConcern" field at all. After adding logic in the PHP library to ignore default read and write concerns in commands (PHPC-976 and PHPLIB-261) I realized that libmongoc was still adding default values for insert, update, and delete.



 Comments   
Comment by Githook User [ 23/Nov/17 ]

Author:

{'name': 'Jeremy Mikola', 'username': 'jmikola', 'email': 'jmikola@gmail.com'}

Message: CDRIVER-2273 add tests for appending default read and write concern
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/b114635fc1cc7c9dec86a412ff03576b48c07e34

Comment by Githook User [ 23/Nov/17 ]

Author:

{'name': 'Jeremy Mikola', 'username': 'jmikola', 'email': 'jmikola@gmail.com'}

Message: CDRIVER-2273 omit default write concern from CRUD commands
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/c2639c821d3c84745bf2dca5629959926a69e973

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