CXX-1748 add read_concern support to find_options#1581
CXX-1748 add read_concern support to find_options#1581EdanStasiuk wants to merge 9 commits intomongodb:masterfrom
Conversation
Add const and non-const internal getters for read_concern so v_noabi::options::find can correctly construct itself from v1::find_options.
|
I'm opening this PR as a draft, as it's my first contribution to this repo. The goal is to add support for setting |
eramongodb
left a comment
There was a problem hiding this comment.
Hello, @EdanStasiuk! Thank you very much for this initial draft PR. The proposed changes are a very good start to addressing CXX-1748.
I plan to extend this functionality across all relevant operations so that read_concern can be used consistently at the per-operation level.
As noted in CXX-1748, recommend limiting the addition of readConcern to option classes which already provide at least one of either writeConcern or readPreference. Quoting the referenced spec which has since been relocated to here:
Since all operations defined in this specification are performed on a collection, it's uncommon that two different read operations on the same collection would use a different read concern, potentially causing mismatched and out-of-sync data. As such, the most natural place to indicate read concern is on the client, the database, or the collection itself and not the operations within it.
However, it might be that a driver needs to expose read concern to a user per operation for various reasons. As noted before, it is permitted to specify this, along with other driver-specific options, in some alternative way.
If you intend to address all relevant option classes in a single PR, feel free to mark this PR as "Ready for Review" once they have all been implemented. If you intend to address each option class individually in separate PRs, feel free to mark this PR as "Ready for Review" once the relevant code for find options class is fully implemented.
|
Hello, @EdanStasiuk. Are you still working on this PR? |
|
@eramongodb yes, I am. Sorry for the delay, I’ve been meaning to come back to this but got caught up with midterms and coursework this semester. I’ll work on addressing the feedback sometime this week. At a glance though, I'll limit the addition of I plan to finish the implementation for |
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Related Ticket: CXX-1748
Summary
This PR introduces support for setting
read_concernonmongocxx::options::findandv1::find_options. Previously, unlikewrite_concernandread_preference,read_concerncould not be set per operation. This change aligns the API with the existing behavior for write concerns and read preferences. Additional PRs will follow to extend this support to other relevant option classes.Core Implementation
read_concernsetter/getter tov1::find_options.v_noabi::findto propagateread_concernfromfind_options.read_concernin internalfind_optionsimplementation.append_toinv1/collection.cppandv_noabi/mongocxx/collection.cppto insertreadConcerninto the BSON options document, ensuring the field is correctly propagated to MongoDB.Tests
read_concernin:v1/find_options.cppv_noabi/options/find.cppv_noabi/collection_mocked.cppread_concerncan be set, retrieved, and passed through mocked collections correctly.