From 736aa56be173ce3de81e1cf660f0dc8aaef4b34c Mon Sep 17 00:00:00 2001 From: "mongodb-dbx-release-bot[bot]" <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 20:01:47 +0000 Subject: [PATCH 1/5] BUMP 4.11.2.dev0 Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com> --- pymongo/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymongo/_version.py b/pymongo/_version.py index 7b72ca9aa6..27294eed13 100644 --- a/pymongo/_version.py +++ b/pymongo/_version.py @@ -18,7 +18,7 @@ import re from typing import List, Tuple, Union -__version__ = "4.11.1" +__version__ = "4.11.2.dev0" def get_version_tuple(version: str) -> Tuple[Union[int, str], ...]: From 315f3cd1b20e2b37a5424279999d5bbfb13652a2 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Mon, 3 Mar 2025 11:30:12 -0800 Subject: [PATCH 2/5] PYTHON-5166 Allow Database.command to run bulkWrite commands (#2164) [v4.11] (#2172) --- doc/changelog.rst | 16 +++++++++++++++- pymongo/message.py | 2 +- test/asynchronous/test_database.py | 15 +++++++++++++++ test/test_database.py | 15 +++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index a1bda74944..66f3efca88 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -1,7 +1,21 @@ Changelog ========= -Changes in Version 4.11.1 (2025/MM/DD) +Changes in Version 4.11.2 (YYYY/MM/DD) +-------------------------------------- + +Version 4.11.2 is a bug fix release. + +- Fixed a bug where :meth:`~pymongo.database.Database.command` would fail when attempting to run the bulkWrite command. + +Issues Resolved +............... + +See the `PyMongo 4.11.2 release notes in JIRA`_ for the list of resolved issues in this release. + +.. _PyMongo 4.11.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=42506 + +Changes in Version 4.11.1 (2025/02/10) -------------------------------------- - Fixed support for prebuilt ``ppc64le`` and ``s390x`` wheels. diff --git a/pymongo/message.py b/pymongo/message.py index 10c9edb5cd..8e2fd6f990 100644 --- a/pymongo/message.py +++ b/pymongo/message.py @@ -105,7 +105,7 @@ "insert": "documents", "update": "updates", "delete": "deletes", - "bulkWrite": "bulkWrite", + "bulkWrite": "ops", } _UNICODE_REPLACE_CODEC_OPTIONS: CodecOptions[Mapping[str, Any]] = CodecOptions( diff --git a/test/asynchronous/test_database.py b/test/asynchronous/test_database.py index 55a8cc3ab2..2bbf763ab3 100644 --- a/test/asynchronous/test_database.py +++ b/test/asynchronous/test_database.py @@ -430,6 +430,21 @@ async def test_command_with_regex(self): for doc in result["cursor"]["firstBatch"]: self.assertTrue(isinstance(doc["r"], Regex)) + async def test_command_bulkWrite(self): + # Ensure bulk write commands can be run directly via db.command(). + if async_client_context.version.at_least(8, 0): + await self.client.admin.command( + { + "bulkWrite": 1, + "nsInfo": [{"ns": self.db.test.full_name}], + "ops": [{"insert": 0, "document": {}}], + } + ) + await self.db.command({"insert": "test", "documents": [{}]}) + await self.db.command({"update": "test", "updates": [{"q": {}, "u": {"$set": {"x": 1}}}]}) + await self.db.command({"delete": "test", "deletes": [{"q": {}, "limit": 1}]}) + await self.db.test.drop() + async def test_cursor_command(self): db = self.client.pymongo_test await db.test.drop() diff --git a/test/test_database.py b/test/test_database.py index aad9089bd8..48cca921b1 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -425,6 +425,21 @@ def test_command_with_regex(self): for doc in result["cursor"]["firstBatch"]: self.assertTrue(isinstance(doc["r"], Regex)) + def test_command_bulkWrite(self): + # Ensure bulk write commands can be run directly via db.command(). + if client_context.version.at_least(8, 0): + self.client.admin.command( + { + "bulkWrite": 1, + "nsInfo": [{"ns": self.db.test.full_name}], + "ops": [{"insert": 0, "document": {}}], + } + ) + self.db.command({"insert": "test", "documents": [{}]}) + self.db.command({"update": "test", "updates": [{"q": {}, "u": {"$set": {"x": 1}}}]}) + self.db.command({"delete": "test", "deletes": [{"q": {}, "limit": 1}]}) + self.db.test.drop() + def test_cursor_command(self): db = self.client.pymongo_test db.test.drop() From 0fa3475835e8bde80a8fa282e1fd690dce84f60e Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Mon, 3 Mar 2025 12:27:35 -0800 Subject: [PATCH 3/5] PYTHON-5155 Use dochub link for fork warning (#2173) [v4.11] (#2174) --- doc/changelog.rst | 3 +-- pymongo/asynchronous/topology.py | 4 +--- pymongo/synchronous/topology.py | 4 +--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index 66f3efca88..cf5d5e8ff7 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -199,7 +199,7 @@ PyMongo 4.9 brings a number of improvements including: unction-as-a-service (FaaS) like AWS Lambda, Google Cloud Functions, and Microsoft Azure Functions. On some FaaS systems, there is a ``fork()`` operation at function startup. By delaying the connection to the first operation, we avoid a deadlock. See - `Is PyMongo Fork-Safe`_ for more information. + :ref:`pymongo-fork-safe` for more information. Issues Resolved @@ -208,7 +208,6 @@ Issues Resolved See the `PyMongo 4.9 release notes in JIRA`_ for the list of resolved issues in this release. -.. _Is PyMongo Fork-Safe : https://www.mongodb.com/docs/languages/python/pymongo-driver/current/faq/#is-pymongo-fork-safe- .. _PyMongo 4.9 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=39940 diff --git a/pymongo/asynchronous/topology.py b/pymongo/asynchronous/topology.py index 6d67710a7e..07671c9a70 100644 --- a/pymongo/asynchronous/topology.py +++ b/pymongo/asynchronous/topology.py @@ -232,9 +232,7 @@ async def open(self) -> None: warnings.warn( # type: ignore[call-overload] # noqa: B028 "AsyncMongoClient opened before fork. May not be entirely fork-safe, " "proceed with caution. See PyMongo's documentation for details: " - "https://www.mongodb.com/docs/languages/" - "python/pymongo-driver/current/faq/" - "#is-pymongo-fork-safe-", + "https://dochub.mongodb.org/core/pymongo-fork-deadlock", **kwargs, ) async with self._lock: diff --git a/pymongo/synchronous/topology.py b/pymongo/synchronous/topology.py index b03269ae43..861712f02a 100644 --- a/pymongo/synchronous/topology.py +++ b/pymongo/synchronous/topology.py @@ -232,9 +232,7 @@ def open(self) -> None: warnings.warn( # type: ignore[call-overload] # noqa: B028 "MongoClient opened before fork. May not be entirely fork-safe, " "proceed with caution. See PyMongo's documentation for details: " - "https://www.mongodb.com/docs/languages/" - "python/pymongo-driver/current/faq/" - "#is-pymongo-fork-safe-", + "https://dochub.mongodb.org/core/pymongo-fork-deadlock", **kwargs, ) with self._lock: From c17011ae7ff7faec7daa25e29693611851b4d4a1 Mon Sep 17 00:00:00 2001 From: "mongodb-dbx-release-bot[bot]" <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 21:14:04 +0000 Subject: [PATCH 4/5] BUMP 4.11.1 Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com> --- pymongo/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymongo/_version.py b/pymongo/_version.py index 27294eed13..7b72ca9aa6 100644 --- a/pymongo/_version.py +++ b/pymongo/_version.py @@ -18,7 +18,7 @@ import re from typing import List, Tuple, Union -__version__ = "4.11.2.dev0" +__version__ = "4.11.1" def get_version_tuple(version: str) -> Tuple[Union[int, str], ...]: From c27fa509fd9617f30d61c8d0964e1907e10517a4 Mon Sep 17 00:00:00 2001 From: "mongodb-dbx-release-bot[bot]" <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 21:16:35 +0000 Subject: [PATCH 5/5] BUMP 4.11.2 Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com> --- pymongo/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymongo/_version.py b/pymongo/_version.py index 7b72ca9aa6..93b9fdacd3 100644 --- a/pymongo/_version.py +++ b/pymongo/_version.py @@ -18,7 +18,7 @@ import re from typing import List, Tuple, Union -__version__ = "4.11.1" +__version__ = "4.11.2" def get_version_tuple(version: str) -> Tuple[Union[int, str], ...]: