Skip to content

Commit 647375c

Browse files
authored
CDRIVER-3052 Replace most uses of mongoc_collection_update (#1423)
1 parent 3e6d56e commit 647375c

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

src/libmongoc/tests/test-mongoc-change-stream.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,12 +1037,12 @@ test_change_stream_live_watch (void *test_ctx)
10371037

10381038
/* Test updating a doc */
10391039
ASSERT_OR_PRINT (
1040-
mongoc_collection_update (coll,
1041-
MONGOC_UPDATE_NONE,
1042-
tmp_bson ("{}"),
1043-
tmp_bson ("{'$set': {'x': 'z'} }"),
1044-
wc,
1045-
&err),
1040+
mongoc_collection_update_one (coll,
1041+
tmp_bson ("{}"),
1042+
tmp_bson ("{'$set': {'x': 'z'} }"),
1043+
&opts,
1044+
NULL,
1045+
&err),
10461046
err);
10471047

10481048
ASSERT (mongoc_change_stream_next (stream, &next_doc));

src/libmongoc/tests/test-mongoc-client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ test_mongoc_client_authenticate_failure (void *context)
754754
* Try various commands while in the failed state to ensure we get the
755755
* same sort of errors.
756756
*/
757-
r = mongoc_collection_update (
758-
collection, MONGOC_UPDATE_NONE, &q, &empty, NULL, &error);
757+
r =
758+
mongoc_collection_update_one (collection, &q, &empty, NULL, NULL, &error);
759759
BSON_ASSERT (!r);
760760
ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_CLIENT);
761761
ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_CLIENT_AUTHENTICATE);

src/libmongoc/tests/test-mongoc-sample-commands.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,9 +2122,7 @@ test_example_52 (mongoc_database_t *db)
21222122
"lastModified", BCON_BOOL (true),
21232123
"}");
21242124

2125-
/* MONGOC_UPDATE_NONE means "no special options" */
2126-
r = mongoc_collection_update (collection, MONGOC_UPDATE_NONE, selector,
2127-
update, NULL, &error);
2125+
r = mongoc_collection_update_one(collection, selector, update, NULL, NULL, &error);
21282126
bson_destroy (selector);
21292127
bson_destroy (update);
21302128

@@ -2179,7 +2177,7 @@ test_example_53 (mongoc_database_t *db)
21792177
"lastModified", BCON_BOOL (true),
21802178
"}");
21812179

2182-
r = mongoc_collection_update (collection, MONGOC_UPDATE_MULTI_UPDATE, selector, update, NULL, &error);
2180+
r = mongoc_collection_update_many(collection, selector, update, NULL, NULL, &error);
21832181
bson_destroy (selector);
21842182
bson_destroy (update);
21852183

@@ -2238,7 +2236,7 @@ test_example_54 (mongoc_database_t *db)
22382236
"]");
22392237

22402238
/* MONGOC_UPDATE_NONE means "no special options" */
2241-
r = mongoc_collection_update (collection, MONGOC_UPDATE_NONE, selector, replacement, NULL, &error);
2239+
r = mongoc_collection_replace_one(collection, selector, replacement, NULL, NULL, &error);
22422240
bson_destroy (selector);
22432241
bson_destroy (replacement);
22442242

@@ -2602,6 +2600,10 @@ accumulate_adoptable_count (const mongoc_client_session_t *cs,
26022600
static void
26032601
test_example_59 (mongoc_database_t *db)
26042602
{
2603+
if (!test_framework_skip_if_no_txns ()) {
2604+
return;
2605+
}
2606+
26052607
mongoc_client_t *client = NULL;
26062608
client = test_framework_new_default_client ();
26072609

@@ -2715,6 +2717,10 @@ retail_setup (mongoc_collection_t *sales_collection)
27152717
static void
27162718
test_example_60 (mongoc_database_t *db)
27172719
{
2720+
if (!test_framework_skip_if_no_txns ()) {
2721+
return;
2722+
}
2723+
27182724
mongoc_client_t *client = NULL;
27192725
client = test_framework_new_default_client ();
27202726

0 commit comments

Comments
 (0)