Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions cratedb_toolkit/adapter/pymongo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 8 additions & 7 deletions cratedb_toolkit/adapter/pymongo/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down