Skip to content

Commit c89350c

Browse files
Fixed bug when an output type handler is used and the value of
cursor.prefetchrows exceeds cursor.arraysize (#173).
1 parent ac12ab2 commit c89350c

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Thin Mode Changes
4141
#) Fixed bug when a connection is discarded from the pool during
4242
:meth:`ConnectionPool.acquire()` and the ping check fails due to the
4343
connection being dead.
44+
#) Fixed bug when an output type handler is used and the value of
45+
cursor.prefetchrows exceeds cursor.arraysize
46+
(`issue 173 <https://github.com/oracle/python-oracledb/issues/173>`__).
4447

4548
Thick Mode Changes
4649
++++++++++++++++++

src/oracledb/impl/base/cursor.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ cdef class BaseCursorImpl:
155155
self._verify_var(var)
156156
var_impl = var._impl
157157
var_impl._fetch_info = fetch_info
158+
if var_impl.num_elements < self._fetch_array_size:
159+
var_impl.num_elements = self._fetch_array_size
160+
var_impl._finalize_init()
158161
self.fetch_vars[pos] = var
159162
self.fetch_var_impls[pos] = var_impl
160163
return 0

tests/test_3900_cursor_execute.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,5 +372,16 @@ def __getitem__(self, index):
372372
order by IntCol""")
373373
self.assertEqual(self.cursor.fetchall(), expected_data)
374374

375+
def test_3929_output_type_handler_with_prefetch_gt_arraysize(self):
376+
"3929 - test an output type handler with prefetch > arraysize"
377+
def type_handler(cursor, name, default_type, size, precision, scale):
378+
return cursor.var(default_type, arraysize=cursor.arraysize)
379+
self.cursor.arraysize = 2
380+
self.cursor.prefetchrows = 3
381+
self.cursor.outputtypehandler = type_handler
382+
self.cursor.execute("select level from dual connect by level <= 5")
383+
self.assertEqual(self.cursor.fetchall(),
384+
[(1,), (2,), (3,), (4,), (5,)])
385+
375386
if __name__ == "__main__":
376387
test_env.run_test_cases()

0 commit comments

Comments
 (0)