diff --git a/cratedb_toolkit/adapter/pymongo/api.py b/cratedb_toolkit/adapter/pymongo/api.py index 2e71fb0d..5a71b459 100644 --- a/cratedb_toolkit/adapter/pymongo/api.py +++ b/cratedb_toolkit/adapter/pymongo/api.py @@ -23,8 +23,8 @@ def __init__(self, dburi: str): patch("pymongo.collection.Collection", collection_patched), patch("pymongo.database.Collection", collection_patched), # Converge a few low-level functions of PyMongo to no-ops. - patch("pymongo.mongo_client.MongoClient._ensure_session"), - patch("pymongo.mongo_client._ClientConnectionRetryable._get_server"), + patch("pymongo.synchronous.mongo_client.MongoClient._ensure_session"), + patch("pymongo.synchronous.mongo_client._ClientConnectionRetryable._get_server"), ] def start(self): diff --git a/cratedb_toolkit/adapter/pymongo/cursor.py b/cratedb_toolkit/adapter/pymongo/cursor.py index 759b9dbe..d84b0616 100644 --- a/cratedb_toolkit/adapter/pymongo/cursor.py +++ b/cratedb_toolkit/adapter/pymongo/cursor.py @@ -9,12 +9,13 @@ import sqlalchemy as sa from bson import SON -from pymongo import CursorType, helpers +from pymongo import CursorType, helpers_shared from pymongo.client_session import ClientSession from pymongo.collation import validate_collation_or_none from pymongo.collection import Collection from pymongo.common import validate_is_document_type, validate_is_mapping -from pymongo.cursor import _QUERY_OPTIONS, Cursor, _Hint, _Sort +from pymongo.cursor import Cursor +from pymongo.cursor_shared import _QUERY_OPTIONS, _Hint, _Sort from pymongo.errors import InvalidOperation from pymongo.message import _GetMore, _Query from pymongo.read_preferences import _ServerMode @@ -119,7 +120,7 @@ def __init__( allow_disk_use = validate_boolean("allow_disk_use", allow_disk_use) if projection is not None: - projection = helpers._fields_list_to_dict(projection, "projection") + projection = helpers_shared._fields_list_to_dict(projection, "projection") if let is not None: validate_is_document_type("let", let) @@ -131,7 +132,7 @@ def __init__( self.__skip = skip self.__limit = limit self.__batch_size = batch_size - self.__ordering = sort and helpers._index_document(sort) or None + self.__ordering = sort and helpers_shared._index_document(sort) or None self.__max_scan = max_scan self.__explain = False self.__comment = comment @@ -287,8 +288,8 @@ def _refresh(self) -> int: def sort(self, key_or_list: _Hint, direction: Optional[Union[int, str]] = None) -> Cursor[_DocumentType]: """ """ - keys = helpers._index_list(key_or_list, direction) - self.__ordering = helpers._index_document(keys) + keys = helpers_shared._index_list(key_or_list, direction) + self.__ordering = helpers_shared._index_document(keys) return self def __send_message(self, operation: Union[_Query, _GetMore]) -> None: @@ -385,6 +386,6 @@ def __set_hint(self, index: Optional[_Hint]) -> None: if isinstance(index, str): self.__hint = index else: - self.__hint = SON(helpers._index_document(index)) + self.__hint = SON(helpers_shared._index_document(index)) return AmendedCursor diff --git a/pyproject.toml b/pyproject.toml index 54eedf35..20767820 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -178,7 +178,7 @@ mongodb = [ pymongo = [ "jessiql==1.0.0rc1", "pandas==2.1.*", - "pymongo<4.9", + "pymongo<4.10,>=4.9.1", "sqlalchemy<2", ] release = [