diff --git a/bindings/python/CHANGELOG.rst b/bindings/python/CHANGELOG.rst index 1f0ad1aba..ce9005b13 100644 --- a/bindings/python/CHANGELOG.rst +++ b/bindings/python/CHANGELOG.rst @@ -4,7 +4,9 @@ Changelog Changes in Version 1.13.0 ------------------------- +- Bundle libmongocrypt 1.13.0 in release wheels. - Add support for the key_expiration_ms option to MongoCryptOptions. +- Add support for $lookup in CSFLE and QE. Changes in Version 1.12.0 ------------------------- diff --git a/bindings/python/pymongocrypt/asynchronous/state_machine.py b/bindings/python/pymongocrypt/asynchronous/state_machine.py index 4468c7c69..579093b28 100644 --- a/bindings/python/pymongocrypt/asynchronous/state_machine.py +++ b/bindings/python/pymongocrypt/asynchronous/state_machine.py @@ -46,7 +46,7 @@ async def collection_info(self, database, filter): - `filter`: The filter to pass to listCollections. :Returns: - The first document from the listCollections command response as BSON. + The all or first document from the listCollections command response as BSON. """ @abstractmethod @@ -125,7 +125,11 @@ async def run_state_machine(ctx, callback): list_colls_filter = ctx.mongo_operation() coll_info = await callback.collection_info(ctx.database, list_colls_filter) if coll_info: - ctx.add_mongo_operation_result(coll_info) + if isinstance(coll_info, list): + for i in coll_info: + ctx.add_mongo_operation_result(i) + else: + ctx.add_mongo_operation_result(coll_info) ctx.complete_mongo_operation() elif state == lib.MONGOCRYPT_CTX_NEED_MONGO_MARKINGS: mongocryptd_cmd = ctx.mongo_operation() diff --git a/bindings/python/pymongocrypt/binding.py b/bindings/python/pymongocrypt/binding.py index c1bd543cf..3d60dc8f7 100644 --- a/bindings/python/pymongocrypt/binding.py +++ b/bindings/python/pymongocrypt/binding.py @@ -31,7 +31,8 @@ def _parse_version(version): # Start embedding from update_binding.py ffi.cdef( - """/* + """ +/* * Copyright 2019-present MongoDB, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -323,6 +324,16 @@ def _parse_version(version): */ bool mongocrypt_setopt_retry_kms(mongocrypt_t *crypt, bool enable); +/** + * Enable support for multiple collection schemas. Required to support $lookup. + * + * @param[in] crypt The @ref mongocrypt_t object. + * @pre @ref mongocrypt_init has not been called on @p crypt. + * @returns A boolean indicating success. If false, an error status is set. + * Retrieve it with @ref mongocrypt_ctx_status + */ +bool mongocrypt_setopt_enable_multiple_collinfo(mongocrypt_t *crypt); + /** * Configure an AWS KMS provider on the @ref mongocrypt_t object. * @@ -1466,6 +1477,10 @@ def _parse_version(version): /// String constants for setopt_query_type // DEPRECATED: Support "rangePreview" has been removed in favor of "range". +/// NOTE: "substringPreview" is experimental and may be removed in a future non-major release. +/// NOTE: "suffixPreview" is experimental and may be removed in a future non-major release. +/// NOTE: "prefixPreview" is experimental and may be removed in a future non-major release. + """ ) # End embedding from update_binding.py diff --git a/bindings/python/pymongocrypt/mongocrypt.py b/bindings/python/pymongocrypt/mongocrypt.py index 87800ed44..608d39e32 100644 --- a/bindings/python/pymongocrypt/mongocrypt.py +++ b/bindings/python/pymongocrypt/mongocrypt.py @@ -96,6 +96,9 @@ def __init(self): if self.__opts.bypass_query_analysis: lib.mongocrypt_setopt_bypass_query_analysis(self.__crypt) + if self.__opts.enable_multiple_collinfo: + lib.mongocrypt_setopt_enable_multiple_collinfo(self.__crypt) + # Prefer using the native crypto binding when we know it's available. try: crypto_available = lib.mongocrypt_is_crypto_available() diff --git a/bindings/python/pymongocrypt/options.py b/bindings/python/pymongocrypt/options.py index 1693bc430..c1e27b1d5 100644 --- a/bindings/python/pymongocrypt/options.py +++ b/bindings/python/pymongocrypt/options.py @@ -12,6 +12,7 @@ def __init__( crypt_shared_lib_required=False, bypass_encryption=False, key_expiration_ms=None, + enable_multiple_collinfo=False, ): """Options for :class:`MongoCrypt`. @@ -156,6 +157,7 @@ def __init__( self.crypt_shared_lib_required = crypt_shared_lib_required self.bypass_encryption = bypass_encryption self.key_expiration_ms = key_expiration_ms + self.enable_multiple_collinfo = enable_multiple_collinfo class ExplicitEncryptOpts: diff --git a/bindings/python/pymongocrypt/synchronous/state_machine.py b/bindings/python/pymongocrypt/synchronous/state_machine.py index 76fb4cd08..c65369b71 100644 --- a/bindings/python/pymongocrypt/synchronous/state_machine.py +++ b/bindings/python/pymongocrypt/synchronous/state_machine.py @@ -46,7 +46,7 @@ def collection_info(self, database, filter): - `filter`: The filter to pass to listCollections. :Returns: - The first document from the listCollections command response as BSON. + The all or first document from the listCollections command response as BSON. """ @abstractmethod @@ -125,7 +125,11 @@ def run_state_machine(ctx, callback): list_colls_filter = ctx.mongo_operation() coll_info = callback.collection_info(ctx.database, list_colls_filter) if coll_info: - ctx.add_mongo_operation_result(coll_info) + if isinstance(coll_info, list): + for i in coll_info: + ctx.add_mongo_operation_result(i) + else: + ctx.add_mongo_operation_result(coll_info) ctx.complete_mongo_operation() elif state == lib.MONGOCRYPT_CTX_NEED_MONGO_MARKINGS: mongocryptd_cmd = ctx.mongo_operation() diff --git a/bindings/python/sbom.json b/bindings/python/sbom.json index 5d59e542f..a5d14914c 100644 --- a/bindings/python/sbom.json +++ b/bindings/python/sbom.json @@ -1,31 +1,31 @@ { "components": [ { - "bom-ref": "pkg:github/mongodb/libmongocrypt@1.12.0", + "bom-ref": "pkg:github/mongodb/libmongocrypt@1.13.0", "externalReferences": [ { "type": "distribution", - "url": "https://github.com/mongodb/libmongocrypt/archive/refs/tags/1.12.0.tar.gz" + "url": "https://github.com/mongodb/libmongocrypt/archive/refs/tags/1.13.0.tar.gz" }, { "type": "website", - "url": "https://github.com/mongodb/libmongocrypt/tree/1.12.0" + "url": "https://github.com/mongodb/libmongocrypt/tree/1.13.0" } ], "group": "mongodb", "name": "libmongocrypt", - "purl": "pkg:github/mongodb/libmongocrypt@1.12.0", + "purl": "pkg:github/mongodb/libmongocrypt@1.13.0", "type": "library", - "version": "1.12.0" + "version": "1.13.0" } ], "dependencies": [ { - "ref": "pkg:github/mongodb/libmongocrypt@1.12.0" + "ref": "pkg:github/mongodb/libmongocrypt@1.13.0" } ], "metadata": { - "timestamp": "2024-12-30T18:25:06.574241+00:00", + "timestamp": "2025-03-17T23:00:23.984416+00:00", "tools": [ { "externalReferences": [ @@ -68,7 +68,7 @@ } ] }, - "serialNumber": "urn:uuid:5e81b4d2-1313-43dd-9ec0-b958d0d71bca", + "serialNumber": "urn:uuid:c500f8af-9297-400c-9624-92eb9584a8aa", "version": 1, "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", "bomFormat": "CycloneDX", diff --git a/bindings/python/scripts/libmongocrypt-version.txt b/bindings/python/scripts/libmongocrypt-version.txt index 0eed1a29e..feaae22ba 100644 --- a/bindings/python/scripts/libmongocrypt-version.txt +++ b/bindings/python/scripts/libmongocrypt-version.txt @@ -1 +1 @@ -1.12.0 +1.13.0 diff --git a/bindings/python/scripts/update_binding.py b/bindings/python/scripts/update_binding.py index 0f1c7c89c..6f13a7651 100644 --- a/bindings/python/scripts/update_binding.py +++ b/bindings/python/scripts/update_binding.py @@ -70,6 +70,8 @@ def update_bindings(): new_lines.append(")") new_lines.append(line) skip = False + with target.open("w") as f: + f.write("\n".join(new_lines)) if __name__ == "__main__":