Skip to content

CXX-2681 Use split min and max setters for RangeOpts #957

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

Merged
merged 3 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .mci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#######################################
variables:

mongoc_version_default: &mongoc_version_default "8aced03a" # TODO: update to 1.24.0 once released.
mongoc_version_default: &mongoc_version_default "11e31e3e" # TODO: update to 1.24.0 once released.

# If updating mongoc_version_minimum, also update:
# - the default value of --c-driver-build-ref in etc/make_release.py
# - LIBMONGOC_REQUIRED_VERSION in src/mongocxx/CMakeLists.txt
mongoc_version_minimum: &mongoc_version_minimum "8aced03a" # TODO: update to 1.24.0 once released.
mongoc_version_minimum: &mongoc_version_minimum "11e31e3e" # TODO: update to 1.24.0 once released.

mongodb_version:
version_latest: &version_latest "latest"
Expand Down
40 changes: 12 additions & 28 deletions etc/make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,10 @@
default='origin',
show_default=True,
help='The remote reference which points to the mongodb/mongo-cxx-driver repo')
@click.option('--c-driver-install-dir',
default=os.getcwd() + '/../mongoc',
show_default=True,
help='When building the C driver and libmongocrypt, install to this directory')
@click.option('--c-driver-build-ref',
default='1.22.1',
default='11e31e3e',
show_default=True,
help='When building the C driver, build at this Git reference')
@click.option('--mongocrypt-build-ref',
default='1.5.2',
show_default=True,
help='When building libmongocrypt, build at this Git reference')
@click.option('--with-c-driver',
help='Instead of building the C driver, use the one installed at this path')
@click.option('--dist-file',
Expand All @@ -119,9 +111,7 @@ def release(jira_creds_file,
github_token_file,
allow_open_issues,
remote,
c_driver_install_dir,
c_driver_build_ref,
mongocrypt_build_ref,
with_c_driver,
dist_file,
skip_distcheck,
Expand Down Expand Up @@ -180,7 +170,7 @@ def release(jira_creds_file,
click.echo('Specified distribution tarball does not exist...exiting!', err=True)
sys.exit(1)
else:
c_driver_dir = ensure_c_driver(c_driver_install_dir, c_driver_build_ref, mongocrypt_build_ref, with_c_driver, quiet)
c_driver_dir = ensure_c_driver(c_driver_build_ref, with_c_driver, quiet)
if not c_driver_dir:
click.echo('C driver not built or not found...exiting!', err=True)
sys.exit(1)
Expand Down Expand Up @@ -331,14 +321,13 @@ def check_pre_release(tag_name):

return not bool(release_re.match(tag_name))

def ensure_c_driver(c_driver_install_dir, c_driver_build_ref, mongocrypt_build_ref, with_c_driver, quiet):
def ensure_c_driver(c_driver_build_ref, with_c_driver, quiet):
"""
Ensures that there is a properly installed C driver, returning the location
of the C driver installation. If the with_c_driver parameter is set and
points to a proper installation of the C driver, then this function simply
returns that directory. Otherwise, delegates to another function to build
the C driver and install it to the directory specified by the
c_driver_install_dir parameter.
the C driver and install it to the mongoc directory.
"""

if with_c_driver:
Expand All @@ -350,32 +339,27 @@ def ensure_c_driver(c_driver_install_dir, c_driver_build_ref, mongocrypt_build_r
click.echo('A required component of the C driver is missing!', err=True)
return None

return build_c_driver(c_driver_install_dir, c_driver_build_ref, mongocrypt_build_ref, quiet)
return build_c_driver(c_driver_build_ref, quiet)

def build_c_driver(c_driver_install_dir, c_driver_build_ref, mongocrypt_build_ref, quiet):
def build_c_driver(c_driver_build_ref, quiet):
"""
Build the C driver and install to the specified directory. If the build is
Build the C driver and install to the mongoc directory. If the build is
successful, then return the directory where the C driver was installed,
otherwise return None.
"""

mongoc_prefix = os.path.abspath(c_driver_install_dir)

if not quiet:
click.echo(f'Building C Driver at {mongoc_prefix} (this could take several minutes)')
click.echo(f'Building C Driver (this could take several minutes)')
click.echo('Pass --with-c-driver to use an existing installation')

env = os.environ.copy()
env['PREFIX'] = mongoc_prefix
env['MONGOC_VERSION'] = c_driver_build_ref
env['MONGOCRYPT_VERSION'] = mongocrypt_build_ref
env['mongoc_version'] = c_driver_build_ref
run_shell_script('./.evergreen/install_c_driver.sh', env=env)

if not quiet:
click.echo('C Driver build was successful.')
click.echo('Version "{}" was installed to "{}".'
.format(c_driver_build_ref, mongoc_prefix))
return mongoc_prefix
click.echo('Build of C Driver version "{}" was successful.'.format(c_driver_build_ref))

return './mongoc'

def build_distribution(release_tag, release_version, c_driver_dir, quiet, skip_distcheck):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/mongocxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ message ("mongocxx version: ${MONGOCXX_VERSION}")
set(MONGOCXX_INLINE_NAMESPACE "v${MONGOCXX_ABI_VERSION}")
set(MONGOCXX_HEADER_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/${MONGOCXX_INLINE_NAMESPACE}" CACHE INTERNAL "")

set(LIBMONGOC_REQUIRED_VERSION 1.22.1)
set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO: update to 1.24.0 once released.
set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0)

set(mongocxx_pkg_dep "")
Expand Down
14 changes: 6 additions & 8 deletions src/mongocxx/options/encrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,14 @@ void* encrypt::convert() const {
const auto& precision = _range_opts->precision();
const auto& sparsity = _range_opts->sparsity();

if (!!min != !!max) {
throw exception{error_code::k_invalid_parameter,
"one of min or max was set without the other"};
if (min) {
libmongoc::client_encryption_encrypt_range_opts_set_min(
range_opts, scoped_bson_value(min->view()).get());
}

if (min && max) {
libmongoc::client_encryption_encrypt_range_opts_set_min_max(
range_opts,
scoped_bson_value(min->view()).get(),
scoped_bson_value(max->view()).get());
if (max) {
libmongoc::client_encryption_encrypt_range_opts_set_max(
range_opts, scoped_bson_value(max->view()).get());
}

if (precision) {
Expand Down
3 changes: 2 additions & 1 deletion src/mongocxx/private/libmongoc_symbols.hh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_encrypt_opts_set_query_type)
MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_encrypt_opts_set_range_opts)
MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_encrypt_range_opts_destroy)
MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_encrypt_range_opts_new)
MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_encrypt_range_opts_set_min_max)
MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_encrypt_range_opts_set_min)
MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_encrypt_range_opts_set_max)
MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_encrypt_range_opts_set_precision)
MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_encrypt_range_opts_set_sparsity)
MONGOCXX_LIBMONGOC_SYMBOL(client_encryption_get_key)
Expand Down