Skip to content

Commit

Permalink
Fixed bug closing a SODA document cursor explicitly (instead of simply
Browse files Browse the repository at this point in the history
allowing it to be closed automatically when it goes out of scope).
  • Loading branch information
anthony-tuininga committed Dec 1, 2022
1 parent f431ad2 commit ec10d76
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/src/release_notes.rst
Expand Up @@ -25,6 +25,8 @@ Thick Mode Changes

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

Common Changes
++++++++++++++
Expand Down
10 changes: 10 additions & 0 deletions src/oracledb/impl/thick/soda.pyx
Expand Up @@ -570,6 +570,16 @@ cdef class ThickSodaDocCursorImpl(BaseSodaDocCursorImpl):
if self._handle != NULL:
dpiSodaDocCursor_release(self._handle)

def close(self):
"""
Internal method for closing the cursor.
"""
cdef int status
with nogil:
status = dpiSodaDocCursor_close(self._handle)
if status < 0:
_raise_from_odpi()

def get_next_doc(self):
"""
Internal method for getting the next document from the cursor.
Expand Down
7 changes: 6 additions & 1 deletion src/oracledb/soda.py
Expand Up @@ -32,7 +32,7 @@
from typing import Union, List
import json

from . import connection
from . import connection, errors

class SodaDatabase:

Expand Down Expand Up @@ -421,6 +421,8 @@ def __iter__(self):
return self

def __next__(self):
if self._impl is None:
errors._raise_err(errors.ERR_CURSOR_NOT_OPEN)
doc_impl = self._impl.get_next_doc()
if doc_impl is not None:
return SodaDocument._from_impl(doc_impl)
Expand All @@ -438,7 +440,10 @@ def close(self) -> None:
cursor will be unusable from this point forward; an Error exception
will be raised if any operation is attempted with the cursor.
"""
if self._impl is None:
errors._raise_err(errors.ERR_CURSOR_NOT_OPEN)
self._impl.close()
self._impl = None


class SodaOperation:
Expand Down

0 comments on commit ec10d76

Please sign in to comment.