Skip to content

Commit 51b0060

Browse files
committed
Make Cursor.close return None when ID is not set
1 parent 4ee5099 commit 51b0060

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

arango/cursor.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,15 @@ def close(self, ignore_missing=False):
283283
:param ignore_missing: Do not raise exception on missing cursors.
284284
:type ignore_missing: bool
285285
:return: True if cursor was closed successfully, False if cursor was
286-
not found and **ignore_missing** was set to True.
287-
:rtype: bool
286+
missing on the server and **ignore_missing** was set to True, None
287+
if there are no cursors to close server-side (e.g. result set is
288+
smaller than the batch size, or in transactions).
289+
:rtype: bool | None
288290
:raise arango.exceptions.CursorCloseError: If operation fails.
289291
:raise arango.exceptions.CursorStateError: If cursor ID is not set.
290292
"""
291293
if self._id is None:
292-
raise CursorStateError('cursor ID not set')
294+
return None
293295
request = Request(
294296
method='delete',
295297
endpoint='/_api/{}/{}'.format(self._type, self._id)

arango/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '4.2.0'
1+
__version__ = '4.2.1'

tests/test_aql.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
AQLQueryTrackingSetError,
1616
AQLQueryKillError,
1717
AQLQueryValidateError,
18-
CursorStateError)
18+
)
1919
from tests.helpers import assert_raises, extract
2020

2121

@@ -114,9 +114,7 @@ def test_aql_query_management(db, bad_db, col, docs):
114114
assert cursor.profile() is None
115115
assert cursor.warnings() is None
116116
assert extract('_key', cursor) == extract('_key', docs)
117-
with assert_raises(CursorStateError) as err:
118-
cursor.close()
119-
assert err.value.message == 'cursor ID not set'
117+
assert cursor.close() is None
120118
else:
121119
assert cursor.id is not None
122120
assert cursor.type == 'cursor'

tests/test_cursor.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,12 @@ def test_cursor_invalid_id(db, col):
183183
cursor.next()
184184
assert err.value.message == 'cursor ID not set'
185185

186-
with pytest.raises(CursorStateError) as err:
187-
cursor.close()
188-
assert err.value.message == 'cursor ID not set'
189-
190186
with pytest.raises(CursorStateError) as err:
191187
cursor.fetch()
192188
assert err.value.message == 'cursor ID not set'
193189

190+
assert cursor.close() is None
191+
194192

195193
def test_cursor_premature_close(db, col, docs):
196194
cursor = db.aql.execute(

0 commit comments

Comments
 (0)