Skip to content

Commit 1cad4ad

Browse files
PYTHON-5162 [pymongocrypt] Bundle libmongocrypt 1.13.0 and PYTHON-5221 Support $lookup in CSFLE and QE (#989)
* [pymongocrypt] Bundle libmongocrypt 1.13.0 * Support $lookup in CSFLE and QE * Update bindings/python/CHANGELOG.rst Co-authored-by: Steven Silvester <[email protected]> --------- Co-authored-by: Steven Silvester <[email protected]>
1 parent 5ec08f0 commit 1cad4ad

File tree

9 files changed

+46
-14
lines changed

9 files changed

+46
-14
lines changed

bindings/python/CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Changelog
44
Changes in Version 1.13.0
55
-------------------------
66

7+
- Bundle libmongocrypt 1.13.0 in release wheels.
78
- Add support for the key_expiration_ms option to MongoCryptOptions.
9+
- Add support for $lookup in CSFLE and QE.
810

911
Changes in Version 1.12.0
1012
-------------------------

bindings/python/pymongocrypt/asynchronous/state_machine.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def collection_info(self, database, filter):
4646
- `filter`: The filter to pass to listCollections.
4747
4848
:Returns:
49-
The first document from the listCollections command response as BSON.
49+
The all or first document from the listCollections command response as BSON.
5050
"""
5151

5252
@abstractmethod
@@ -125,7 +125,11 @@ async def run_state_machine(ctx, callback):
125125
list_colls_filter = ctx.mongo_operation()
126126
coll_info = await callback.collection_info(ctx.database, list_colls_filter)
127127
if coll_info:
128-
ctx.add_mongo_operation_result(coll_info)
128+
if isinstance(coll_info, list):
129+
for i in coll_info:
130+
ctx.add_mongo_operation_result(i)
131+
else:
132+
ctx.add_mongo_operation_result(coll_info)
129133
ctx.complete_mongo_operation()
130134
elif state == lib.MONGOCRYPT_CTX_NEED_MONGO_MARKINGS:
131135
mongocryptd_cmd = ctx.mongo_operation()

bindings/python/pymongocrypt/binding.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def _parse_version(version):
3131

3232
# Start embedding from update_binding.py
3333
ffi.cdef(
34-
"""/*
34+
"""
35+
/*
3536
* Copyright 2019-present MongoDB, Inc.
3637
*
3738
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -323,6 +324,16 @@ def _parse_version(version):
323324
*/
324325
bool mongocrypt_setopt_retry_kms(mongocrypt_t *crypt, bool enable);
325326
327+
/**
328+
* Enable support for multiple collection schemas. Required to support $lookup.
329+
*
330+
* @param[in] crypt The @ref mongocrypt_t object.
331+
* @pre @ref mongocrypt_init has not been called on @p crypt.
332+
* @returns A boolean indicating success. If false, an error status is set.
333+
* Retrieve it with @ref mongocrypt_ctx_status
334+
*/
335+
bool mongocrypt_setopt_enable_multiple_collinfo(mongocrypt_t *crypt);
336+
326337
/**
327338
* Configure an AWS KMS provider on the @ref mongocrypt_t object.
328339
*
@@ -1466,6 +1477,10 @@ def _parse_version(version):
14661477
14671478
/// String constants for setopt_query_type
14681479
// DEPRECATED: Support "rangePreview" has been removed in favor of "range".
1480+
/// NOTE: "substringPreview" is experimental and may be removed in a future non-major release.
1481+
/// NOTE: "suffixPreview" is experimental and may be removed in a future non-major release.
1482+
/// NOTE: "prefixPreview" is experimental and may be removed in a future non-major release.
1483+
14691484
"""
14701485
)
14711486
# End embedding from update_binding.py

bindings/python/pymongocrypt/mongocrypt.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ def __init(self):
9696
if self.__opts.bypass_query_analysis:
9797
lib.mongocrypt_setopt_bypass_query_analysis(self.__crypt)
9898

99+
if self.__opts.enable_multiple_collinfo:
100+
lib.mongocrypt_setopt_enable_multiple_collinfo(self.__crypt)
101+
99102
# Prefer using the native crypto binding when we know it's available.
100103
try:
101104
crypto_available = lib.mongocrypt_is_crypto_available()

bindings/python/pymongocrypt/options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def __init__(
1212
crypt_shared_lib_required=False,
1313
bypass_encryption=False,
1414
key_expiration_ms=None,
15+
enable_multiple_collinfo=False,
1516
):
1617
"""Options for :class:`MongoCrypt`.
1718
@@ -156,6 +157,7 @@ def __init__(
156157
self.crypt_shared_lib_required = crypt_shared_lib_required
157158
self.bypass_encryption = bypass_encryption
158159
self.key_expiration_ms = key_expiration_ms
160+
self.enable_multiple_collinfo = enable_multiple_collinfo
159161

160162

161163
class ExplicitEncryptOpts:

bindings/python/pymongocrypt/synchronous/state_machine.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def collection_info(self, database, filter):
4646
- `filter`: The filter to pass to listCollections.
4747
4848
:Returns:
49-
The first document from the listCollections command response as BSON.
49+
The all or first document from the listCollections command response as BSON.
5050
"""
5151

5252
@abstractmethod
@@ -125,7 +125,11 @@ def run_state_machine(ctx, callback):
125125
list_colls_filter = ctx.mongo_operation()
126126
coll_info = callback.collection_info(ctx.database, list_colls_filter)
127127
if coll_info:
128-
ctx.add_mongo_operation_result(coll_info)
128+
if isinstance(coll_info, list):
129+
for i in coll_info:
130+
ctx.add_mongo_operation_result(i)
131+
else:
132+
ctx.add_mongo_operation_result(coll_info)
129133
ctx.complete_mongo_operation()
130134
elif state == lib.MONGOCRYPT_CTX_NEED_MONGO_MARKINGS:
131135
mongocryptd_cmd = ctx.mongo_operation()

bindings/python/sbom.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
{
22
"components": [
33
{
4-
"bom-ref": "pkg:github/mongodb/libmongocrypt@1.12.0",
4+
"bom-ref": "pkg:github/mongodb/libmongocrypt@1.13.0",
55
"externalReferences": [
66
{
77
"type": "distribution",
8-
"url": "https://github.com/mongodb/libmongocrypt/archive/refs/tags/1.12.0.tar.gz"
8+
"url": "https://github.com/mongodb/libmongocrypt/archive/refs/tags/1.13.0.tar.gz"
99
},
1010
{
1111
"type": "website",
12-
"url": "https://github.com/mongodb/libmongocrypt/tree/1.12.0"
12+
"url": "https://github.com/mongodb/libmongocrypt/tree/1.13.0"
1313
}
1414
],
1515
"group": "mongodb",
1616
"name": "libmongocrypt",
17-
"purl": "pkg:github/mongodb/libmongocrypt@1.12.0",
17+
"purl": "pkg:github/mongodb/libmongocrypt@1.13.0",
1818
"type": "library",
19-
"version": "1.12.0"
19+
"version": "1.13.0"
2020
}
2121
],
2222
"dependencies": [
2323
{
24-
"ref": "pkg:github/mongodb/libmongocrypt@1.12.0"
24+
"ref": "pkg:github/mongodb/libmongocrypt@1.13.0"
2525
}
2626
],
2727
"metadata": {
28-
"timestamp": "2024-12-30T18:25:06.574241+00:00",
28+
"timestamp": "2025-03-17T23:00:23.984416+00:00",
2929
"tools": [
3030
{
3131
"externalReferences": [
@@ -68,7 +68,7 @@
6868
}
6969
]
7070
},
71-
"serialNumber": "urn:uuid:5e81b4d2-1313-43dd-9ec0-b958d0d71bca",
71+
"serialNumber": "urn:uuid:c500f8af-9297-400c-9624-92eb9584a8aa",
7272
"version": 1,
7373
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
7474
"bomFormat": "CycloneDX",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.12.0
1+
1.13.0

bindings/python/scripts/update_binding.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def update_bindings():
7070
new_lines.append(")")
7171
new_lines.append(line)
7272
skip = False
73+
with target.open("w") as f:
74+
f.write("\n".join(new_lines))
7375

7476

7577
if __name__ == "__main__":

0 commit comments

Comments
 (0)