Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDRIVER-5935 remove deprecated bson_copy_to_excluding #1946

Merged
merged 2 commits into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/libbson/NEWS
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ libbson 2.0.0 (Unreleased)
* `bson_t` and `bson_iter_t` are now aligned to the size of a pointer instead of `128`.
* `bson_error_t`, `bson_value_t`, and `bson_visitor_t` are now aligned to the size of a pointer instead of `8`.
* `BSON_ALIGNED_BEGIN` and `BSON_ALIGNED_END` now unconditionally apply their requested alignment.
* Remove deprecated `bson_copy_to_excluding`. Use `bson_copy_to_excluding_noinit` instead.


libbson 1.30.2
39 changes: 0 additions & 39 deletions src/libbson/doc/bson_copy_to_excluding.rst

This file was deleted.

5 changes: 2 additions & 3 deletions src/libbson/doc/bson_copy_to_excluding_noinit.rst
Original file line number Diff line number Diff line change
@@ -27,9 +27,8 @@ Description
The :symbol:`bson_copy_to_excluding_noinit()` function shall copy all fields
from ``src`` to ``dst`` except those specified by the variadic, NULL terminated
list of keys starting from ``first_exclude``.
Works the same way as :symbol:`bson_copy_to_excluding`, except does **not** call
:symbol:`bson_init` on ``dst``.
This function should be preferred in new code over :symbol:`bson_copy_to_excluding`.

Does **not** call :symbol:`bson_init` on ``dst``.

.. warning::

2 changes: 1 addition & 1 deletion src/libbson/doc/bson_copy_to_excluding_noinit_va.rst
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ Description

The :symbol:`bson_copy_to_excluding_noinit_va()` function shall copy all fields from ``src`` to ``dst`` except those specified by ``first_exclude`` and ``args``.

This method works the same way as :symbol:`bson_copy_to_excluding_noinit`, except it takes a va_list. This method does not call :symbol:`bson_init` on ``dst``.
Does **not** call :symbol:`bson_init` on ``dst``.

.. seealso::

1 change: 0 additions & 1 deletion src/libbson/doc/bson_t.rst
Original file line number Diff line number Diff line change
@@ -204,7 +204,6 @@ BSON document contains duplicate keys.
bson_concat
bson_copy
bson_copy_to
bson_copy_to_excluding
bson_copy_to_excluding_noinit
bson_copy_to_excluding_noinit_va
bson_count_keys
16 changes: 0 additions & 16 deletions src/libbson/src/bson/bson.c
Original file line number Diff line number Diff line change
@@ -2184,22 +2184,6 @@ bson_copy_to_excluding_noinit_va (const bson_t *src, bson_t *dst, const char *fi
}


void
bson_copy_to_excluding (const bson_t *src, bson_t *dst, const char *first_exclude, ...)
{
va_list args;

BSON_ASSERT (src);
BSON_ASSERT (dst);
BSON_ASSERT (first_exclude);

bson_init (dst);

va_start (args, first_exclude);
bson_copy_to_excluding_noinit_va (src, dst, first_exclude, args);
va_end (args);
}

void
bson_copy_to_excluding_noinit (const bson_t *src, bson_t *dst, const char *first_exclude, ...)
{
20 changes: 1 addition & 19 deletions src/libbson/src/bson/bson.h
Original file line number Diff line number Diff line change
@@ -288,31 +288,13 @@ bson_copy (const bson_t *bson);
BSON_EXPORT (void)
bson_copy_to (const bson_t *src, bson_t *dst);


/**
* bson_copy_to_excluding:
* @src: A bson_t.
* @dst: A bson_t to initialize and copy into.
* @first_exclude: First field name to exclude.
*
* Copies @src into @dst excluding any field that is provided.
* This is handy for situations when you need to remove one or
* more fields in a bson_t. Note that bson_init() will be called
* on dst.
*/
BSON_DEPRECATED_FOR (bson_copy_to_excluding_noinit)
BSON_EXPORT (void)
bson_copy_to_excluding (const bson_t *src, bson_t *dst, const char *first_exclude, ...) BSON_GNUC_NULL_TERMINATED;

/**
* bson_copy_to_excluding_noinit:
* @src: A bson_t.
* @dst: A bson_t to initialize and copy into.
* @first_exclude: First field name to exclude.
*
* The same as bson_copy_to_excluding, but does not call bson_init()
* on the dst. This version should be preferred in new code, but the
* old function is left for backwards compatibility.
* Does not call bson_init() on the dst.
*/
BSON_EXPORT (void)
bson_copy_to_excluding_noinit (const bson_t *src, bson_t *dst, const char *first_exclude, ...)
4 changes: 2 additions & 2 deletions src/libmongoc/tests/json-test.c
Original file line number Diff line number Diff line change
@@ -1374,12 +1374,12 @@ set_auto_encryption_opts (mongoc_client_t *client, bson_t *test)
auto_encryption_opts = mongoc_auto_encryption_opts_new ();

if (bson_iter_init_find (&iter, &opts, "kmsProviders")) {
bson_t kms_providers;
bson_t kms_providers = BSON_INITIALIZER;
bson_t tls_opts = BSON_INITIALIZER;
bson_t tmp;

bson_iter_bson (&iter, &tmp);
bson_copy_to_excluding (
bson_copy_to_excluding_noinit (
&tmp, &kms_providers, "aws", "awsTemporary", "awsTemporaryNoSessionToken", "azure", "gcp", "kmip", NULL);

/* AWS credentials are set from environment variables. */
4 changes: 2 additions & 2 deletions src/libmongoc/tests/test-mongoc-connection-uri.c
Original file line number Diff line number Diff line change
@@ -306,8 +306,8 @@ run_uri_test (const char *uri_string,

// CDRIVER-4128: CANONICALIZE_HOST_NAME is UTF-8 even when "false" or "true".
{
bson_t updated;
bson_copy_to_excluding (&expected_props, &updated, "CANONICALIZE_HOST_NAME", NULL);
bson_t updated = BSON_INITIALIZER;
bson_copy_to_excluding_noinit (&expected_props, &updated, "CANONICALIZE_HOST_NAME", NULL);
if (bson_iter_init_find_case (&iter, &expected_props, "CANONICALIZE_HOST_NAME")) {
if (BSON_ITER_HOLDS_BOOL (&iter)) {
BSON_APPEND_UTF8 (
4 changes: 2 additions & 2 deletions src/libmongoc/tests/unified/operation.c
Original file line number Diff line number Diff line change
@@ -4325,7 +4325,7 @@ operation_run (test_t *test, bson_t *op_bson, bson_error_t *error)
/* Check for a "session" argument in all operations, it can be
* an argument for any operation. */
if (op->arguments && bson_has_field (op->arguments, "session")) {
bson_t copied;
bson_t copied = BSON_INITIALIZER;
mongoc_client_session_t *session = NULL;

op->session_id = bson_strdup (bson_lookup_utf8 (op->arguments, "session"));
@@ -4335,7 +4335,7 @@ operation_run (test_t *test, bson_t *op_bson, bson_error_t *error)
goto done;
}

bson_copy_to_excluding (op->arguments, &copied, "session", NULL);
bson_copy_to_excluding_noinit (op->arguments, &copied, "session", NULL);
bson_destroy (op->arguments);
op->arguments = bson_copy (&copied);
bson_destroy (&copied);