v1: database (CXX-3237, CXX-3238)#1564
Merged
eramongodb merged 7 commits intomongodb:masterfrom Jan 26, 2026
Merged
Conversation
kevinAlbs
approved these changes
Jan 26, 2026
Collaborator
kevinAlbs
left a comment
There was a problem hiding this comment.
LGTM with minor test suggestions and possible further reuse.
| auto const input = GENERATE("a", "b", "c"); | ||
|
|
||
| database_destroy->interpose([&](mongoc_database_t* ptr) -> void { | ||
| if (ptr) { |
Collaborator
There was a problem hiding this comment.
Minor: but I expect the if (ptr) is not needed.
| REQUIRE(reply != nullptr); | ||
| REQUIRE(error != nullptr); | ||
|
|
||
| set_client_error(error); |
Collaborator
There was a problem hiding this comment.
Suggested change
| set_client_error(error); | |
| set_server_error(error); |
Minor test discrepancy. I expect this is still thrown as a server error because the reply has a "code" field.
Contributor
Author
There was a problem hiding this comment.
Good catch. Updated as suggested.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves CXX-3237 and CXX-3238 for the
v1::databasecomponent and implements dependent functions inv1::client.Similar to prior PRs, some parameter types are updated for better consistency with their ownership semantics. An incorrect
constqualifier on.has_collection()inherited from v_noabi is also removed.The most notable difference between the former v_noabi implementation and the new v1 implementation is that the
std::string name;internal data member is removed in favor of callingmongoc_database_get_name(). This change requires updating some v_noabi mocked database tests to satisfy the expected call to.name()(both explicitly and internally) when the database object may not be backed by an actualmongoc_database_tobject (_impl == nullptr). However, this behavior should not be observable to public API users ofv_noabi::database.Another notable change is that the v1 implementation of
.has_collection()checks forerror.code != 0rather than the v_noabi implemention which checkserror.domain != 0. Although I do not expect this makes any practical difference given the behavior of the mongoc library, it is a notable change consistent with the general improvements by v1 API to mongocxx's error handling behavior w.r.t. error codes and error categories.Lastly, similar to what was done for
client::watch(), the v1 implementation ofdatabase::watch()avoids the need to create an intermediate BSON document of the form{"pipeline": [...]}in favor of simply passing[...]directly and allowing mongoc to create the pipeline field instead. However, the v_noabi implementation continues to create the"pipeline"field manually for backward compatibility with existing v_noabi mocked tests. Although this is not strictly necessary as it is internally-observable-only behavior, it nevertheless keeps the changes to v_noabi test code minimal to help validate backward compatibility of the v_noabi refactor. Where permitted, the v1 implementation also tries to passnullptras argument for optional parameters to avoid redundant work parsing emptybson_tdocuments.