Skip to content

PYTHON-5046 Support $lookup in CSFLE and QE #2210

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 20 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PyMongo 4.12 brings a number of changes including:

- Support for configuring DEK cache lifetime via the ``key_expiration_ms`` argument to
:class:`~pymongo.encryption_options.AutoEncryptionOpts`.
- Support for $lookup in CSFLE and QE.pr
- Support for $lookup in CSFLE and QE supported on MongoDB 8.1+.

Issues Resolved
...............
Expand Down
12 changes: 12 additions & 0 deletions test/asynchronous/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,9 @@ async def asyncSetUp(self):
await encrypted_client.db.no_schema.insert_one({"no_schema": "no_schema"})
await encrypted_client.db.no_schema2.insert_one({"no_schema2": "no_schema2"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add:

await encrypted_client.close()
await unencrypted_client.close()


await encrypted_client.close()
await unencrypted_client.close()

@async_client_context.require_version_min(8, 1, -1)
async def test_1_csfle_joins_no_schema(self):
encrypted_client = await self.async_rs_or_single_client(
Expand Down Expand Up @@ -2499,6 +2502,7 @@ async def test_1_csfle_joins_no_schema(self):
)
)
self.assertEqual(doc, {"csfle": "csfle", "matched": [{"no_schema": "no_schema"}]})
await encrypted_client.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing the clients in the tests isn't needed since they're closed at tear down anyway. The reason I asked to close the clients in asyncSetUp is because otherwise they remain open for the entire test and compete with other tasks that need to be scheduled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh okay, i see. fixed


@async_client_context.require_version_min(8, 1, -1)
async def test_2_qe_joins_no_schema(self):
Expand Down Expand Up @@ -2527,6 +2531,7 @@ async def test_2_qe_joins_no_schema(self):
)
)
self.assertEqual(doc, {"qe": "qe", "matched": [{"no_schema": "no_schema"}]})
await encrypted_client.close()

@async_client_context.require_version_min(8, 1, -1)
async def test_3_no_schema_joins_csfle(self):
Expand All @@ -2552,6 +2557,7 @@ async def test_3_no_schema_joins_csfle(self):
)
)
self.assertEqual(doc, {"no_schema": "no_schema", "matched": [{"csfle": "csfle"}]})
await encrypted_client.close()

@async_client_context.require_version_min(8, 1, -1)
async def test_4_no_schema_joins_qe(self):
Expand Down Expand Up @@ -2580,6 +2586,7 @@ async def test_4_no_schema_joins_qe(self):
)
)
self.assertEqual(doc, {"no_schema": "no_schema", "matched": [{"qe": "qe"}]})
await encrypted_client.close()

@async_client_context.require_version_min(8, 1, -1)
async def test_5_csfle_joins_csfle2(self):
Expand Down Expand Up @@ -2608,6 +2615,7 @@ async def test_5_csfle_joins_csfle2(self):
)
)
self.assertEqual(doc, {"csfle": "csfle", "matched": [{"csfle2": "csfle2"}]})
await encrypted_client.close()

@async_client_context.require_version_min(8, 1, -1)
async def test_6_qe_joins_qe2(self):
Expand Down Expand Up @@ -2636,6 +2644,7 @@ async def test_6_qe_joins_qe2(self):
)
)
self.assertEqual(doc, {"qe": "qe", "matched": [{"qe2": "qe2"}]})
await encrypted_client.close()

@async_client_context.require_version_min(8, 1, -1)
async def test_7_no_schema_joins_no_schema2(self):
Expand Down Expand Up @@ -2664,6 +2673,7 @@ async def test_7_no_schema_joins_no_schema2(self):
)
)
self.assertEqual(doc, {"no_schema": "no_schema", "matched": [{"no_schema2": "no_schema2"}]})
await encrypted_client.close()

@async_client_context.require_version_min(8, 1, -1)
async def test_8_csfle_joins_qe(self):
Expand All @@ -2690,6 +2700,7 @@ async def test_8_csfle_joins_qe(self):
)
)
self.assertTrue("not supported" in str(exc))
await encrypted_client.close()

@async_client_context.require_version_max(8, 1, -1)
async def test_9_error(self):
Expand Down Expand Up @@ -2719,6 +2730,7 @@ async def test_9_error(self):
)
)
self.assertTrue("Upgrade" in str(exc))
await encrypted_client.close()


# https://github.com/mongodb/specifications/blob/072601/source/client-side-encryption/tests/README.md#rewrap
Expand Down
12 changes: 12 additions & 0 deletions test/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -2456,6 +2456,9 @@ def setUp(self):
encrypted_client.db.no_schema.insert_one({"no_schema": "no_schema"})
encrypted_client.db.no_schema2.insert_one({"no_schema2": "no_schema2"})

encrypted_client.close()
unencrypted_client.close()

@client_context.require_version_min(8, 1, -1)
def test_1_csfle_joins_no_schema(self):
encrypted_client = self.rs_or_single_client(
Expand Down Expand Up @@ -2483,6 +2486,7 @@ def test_1_csfle_joins_no_schema(self):
)
)
self.assertEqual(doc, {"csfle": "csfle", "matched": [{"no_schema": "no_schema"}]})
encrypted_client.close()

@client_context.require_version_min(8, 1, -1)
def test_2_qe_joins_no_schema(self):
Expand Down Expand Up @@ -2511,6 +2515,7 @@ def test_2_qe_joins_no_schema(self):
)
)
self.assertEqual(doc, {"qe": "qe", "matched": [{"no_schema": "no_schema"}]})
encrypted_client.close()

@client_context.require_version_min(8, 1, -1)
def test_3_no_schema_joins_csfle(self):
Expand All @@ -2536,6 +2541,7 @@ def test_3_no_schema_joins_csfle(self):
)
)
self.assertEqual(doc, {"no_schema": "no_schema", "matched": [{"csfle": "csfle"}]})
encrypted_client.close()

@client_context.require_version_min(8, 1, -1)
def test_4_no_schema_joins_qe(self):
Expand Down Expand Up @@ -2564,6 +2570,7 @@ def test_4_no_schema_joins_qe(self):
)
)
self.assertEqual(doc, {"no_schema": "no_schema", "matched": [{"qe": "qe"}]})
encrypted_client.close()

@client_context.require_version_min(8, 1, -1)
def test_5_csfle_joins_csfle2(self):
Expand Down Expand Up @@ -2592,6 +2599,7 @@ def test_5_csfle_joins_csfle2(self):
)
)
self.assertEqual(doc, {"csfle": "csfle", "matched": [{"csfle2": "csfle2"}]})
encrypted_client.close()

@client_context.require_version_min(8, 1, -1)
def test_6_qe_joins_qe2(self):
Expand Down Expand Up @@ -2620,6 +2628,7 @@ def test_6_qe_joins_qe2(self):
)
)
self.assertEqual(doc, {"qe": "qe", "matched": [{"qe2": "qe2"}]})
encrypted_client.close()

@client_context.require_version_min(8, 1, -1)
def test_7_no_schema_joins_no_schema2(self):
Expand Down Expand Up @@ -2648,6 +2657,7 @@ def test_7_no_schema_joins_no_schema2(self):
)
)
self.assertEqual(doc, {"no_schema": "no_schema", "matched": [{"no_schema2": "no_schema2"}]})
encrypted_client.close()

@client_context.require_version_min(8, 1, -1)
def test_8_csfle_joins_qe(self):
Expand All @@ -2674,6 +2684,7 @@ def test_8_csfle_joins_qe(self):
)
)
self.assertTrue("not supported" in str(exc))
encrypted_client.close()

@client_context.require_version_max(8, 1, -1)
def test_9_error(self):
Expand Down Expand Up @@ -2703,6 +2714,7 @@ def test_9_error(self):
)
)
self.assertTrue("Upgrade" in str(exc))
encrypted_client.close()


# https://github.com/mongodb/specifications/blob/072601/source/client-side-encryption/tests/README.md#rewrap
Expand Down
Loading