Skip to content

Commit 21b75d6

Browse files
committed
MongoDB: Update adapter to pymongo 4.9
pymongo 4.9 has been released, and includes a few breaking API changes after adding an asynchronous variant to the driver.
1 parent d3c7cfe commit 21b75d6

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

cratedb_toolkit/adapter/pymongo/cursor.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99

1010
import sqlalchemy as sa
1111
from bson import SON
12-
from pymongo import CursorType, helpers
12+
from pymongo import CursorType, helpers_shared
1313
from pymongo.client_session import ClientSession
1414
from pymongo.collation import validate_collation_or_none
1515
from pymongo.collection import Collection
1616
from pymongo.common import validate_is_document_type, validate_is_mapping
17-
from pymongo.cursor import _QUERY_OPTIONS, Cursor, _Hint, _Sort
17+
from pymongo.cursor import Cursor
18+
from pymongo.cursor_shared import _QUERY_OPTIONS, _Hint, _Sort
1819
from pymongo.errors import InvalidOperation
1920
from pymongo.message import _GetMore, _Query
2021
from pymongo.read_preferences import _ServerMode
@@ -119,7 +120,7 @@ def __init__(
119120
allow_disk_use = validate_boolean("allow_disk_use", allow_disk_use)
120121

121122
if projection is not None:
122-
projection = helpers._fields_list_to_dict(projection, "projection")
123+
projection = helpers_shared._fields_list_to_dict(projection, "projection")
123124

124125
if let is not None:
125126
validate_is_document_type("let", let)
@@ -131,7 +132,7 @@ def __init__(
131132
self.__skip = skip
132133
self.__limit = limit
133134
self.__batch_size = batch_size
134-
self.__ordering = sort and helpers._index_document(sort) or None
135+
self.__ordering = sort and helpers_shared._index_document(sort) or None
135136
self.__max_scan = max_scan
136137
self.__explain = False
137138
self.__comment = comment
@@ -287,8 +288,8 @@ def _refresh(self) -> int:
287288

288289
def sort(self, key_or_list: _Hint, direction: Optional[Union[int, str]] = None) -> Cursor[_DocumentType]:
289290
""" """
290-
keys = helpers._index_list(key_or_list, direction)
291-
self.__ordering = helpers._index_document(keys)
291+
keys = helpers_shared._index_list(key_or_list, direction)
292+
self.__ordering = helpers_shared._index_document(keys)
292293
return self
293294

294295
def __send_message(self, operation: Union[_Query, _GetMore]) -> None:
@@ -385,6 +386,6 @@ def __set_hint(self, index: Optional[_Hint]) -> None:
385386
if isinstance(index, str):
386387
self.__hint = index
387388
else:
388-
self.__hint = SON(helpers._index_document(index))
389+
self.__hint = SON(helpers_shared._index_document(index))
389390

390391
return AmendedCursor

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ mongodb = [
178178
pymongo = [
179179
"jessiql==1.0.0rc1",
180180
"pandas==2.1.*",
181-
"pymongo<4.9",
181+
"pymongo<4.10,>=4.9.1",
182182
"sqlalchemy<2",
183183
]
184184
release = [

0 commit comments

Comments
 (0)