Skip to content

Commit 974b25a

Browse files
authored
PYTHON-3050 Add session support to find_raw_batches (#41)
1 parent ea92e15 commit 974b25a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

bindings/python/pymongoarrow/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def find_arrow_all(collection, query, *, schema, **kwargs):
5858
context = PyMongoArrowContext.from_schema(
5959
schema, codec_options=collection.codec_options)
6060

61-
for opt in ('session', 'cursor_type'):
61+
for opt in ('cursor_type',):
6262
if kwargs.pop(opt, None):
6363
warnings.warn(
6464
f'Ignoring option {opt!r} as it is not supported by '

bindings/python/test/test_arrow.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_find_simple(self):
7272
self.assertEqual(find_cmd.command['projection'],
7373
{'_id': True, 'data': True})
7474

75-
def test_find_projection(self):
75+
def test_find_with_projection(self):
7676
expected = Table.from_pydict(
7777
{'_id': [4, 3], 'data': [None, 60]},
7878
ArrowSchema([('_id', int32()), ('data', int64())]))
@@ -87,6 +87,17 @@ def test_find_projection(self):
8787
self.assertEqual(find_cmd.command_name, 'find')
8888
self.assertEqual(find_cmd.command['projection'], projection)
8989

90+
def test_find_with_session(self):
91+
with self.client.start_session() as session:
92+
self.assertIsNone(session.operation_time)
93+
last_use = session._server_session.last_use
94+
expected = Table.from_pydict(
95+
{'_id': [1, 2, 3, 4], 'data': [10, 20, 30, None]},
96+
ArrowSchema([('_id', int32()), ('data', int64())]))
97+
table = self.run_find({}, schema=self.schema, session=session)
98+
self.assertEqual(table, expected)
99+
self.assertIsNotNone(session.operation_time)
100+
90101
def test_find_multiple_batches(self):
91102
orig_method = self.coll.find_raw_batches
92103

0 commit comments

Comments
 (0)