Recently on SERVER-43712 there was a need to update QueryRequest to distinguish between absent (unspecified) readConcern, and readConcern which is an empty sub-object.
This was done by changing _readConcern from BSONObj to boost::optional<BSONObj>, but this results in some awkwardness when preserving the getReadConcern() return value of const BSONObj& (because return _readConcern.value_or(BSONObj()); would return a reference to a temporary), and other awkwardness when interacting with the readConcern on the opCtx.
An alternative would be to keep _readConcern as BSONObj and have a bool _readConcernHasBeenSet = false; alongside it. But this would be ugly and clunky in other ways, by having to maintain and coordinate these tandem variables.
It might be better if _readConcern was updated to be of type ReadConcernArgs instead, since this is the more natural representation of read concern (eg. it can easily and correctly distinguish between unspecified and empty readConcerns).
- related to
-
SERVER-43712 Use RWCDefaults for incoming requests (mongos)
- Closed