Skip to content

Commit ec10d76

Browse files
Fixed bug closing a SODA document cursor explicitly (instead of simply
allowing it to be closed automatically when it goes out of scope).
1 parent f431ad2 commit ec10d76

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

doc/src/release_notes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Thick Mode Changes
2525

2626
#) Fixed bug creating a homogeneous connection pool with a proxy user
2727
(`issue 101 <https://github.com/oracle/python-oracledb/issues/101>`__).
28+
#) Fixed bug closing a SODA document cursor explicitly (instead of simply
29+
allowing it to be closed automatically when it goes out of scope).
2830

2931
Common Changes
3032
++++++++++++++

src/oracledb/impl/thick/soda.pyx

+10
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,16 @@ cdef class ThickSodaDocCursorImpl(BaseSodaDocCursorImpl):
570570
if self._handle != NULL:
571571
dpiSodaDocCursor_release(self._handle)
572572

573+
def close(self):
574+
"""
575+
Internal method for closing the cursor.
576+
"""
577+
cdef int status
578+
with nogil:
579+
status = dpiSodaDocCursor_close(self._handle)
580+
if status < 0:
581+
_raise_from_odpi()
582+
573583
def get_next_doc(self):
574584
"""
575585
Internal method for getting the next document from the cursor.

src/oracledb/soda.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from typing import Union, List
3333
import json
3434

35-
from . import connection
35+
from . import connection, errors
3636

3737
class SodaDatabase:
3838

@@ -421,6 +421,8 @@ def __iter__(self):
421421
return self
422422

423423
def __next__(self):
424+
if self._impl is None:
425+
errors._raise_err(errors.ERR_CURSOR_NOT_OPEN)
424426
doc_impl = self._impl.get_next_doc()
425427
if doc_impl is not None:
426428
return SodaDocument._from_impl(doc_impl)
@@ -438,7 +440,10 @@ def close(self) -> None:
438440
cursor will be unusable from this point forward; an Error exception
439441
will be raised if any operation is attempted with the cursor.
440442
"""
443+
if self._impl is None:
444+
errors._raise_err(errors.ERR_CURSOR_NOT_OPEN)
441445
self._impl.close()
446+
self._impl = None
442447

443448

444449
class SodaOperation:

0 commit comments

Comments
 (0)