Skip to content

Commit 25e3890

Browse files
Fixed bug when calling execute() or executemany() with missing bind data
after calling setinputsizes() with at least one of the parameters passed as the value "None" (#217).
1 parent e861b2b commit 25e3890

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

doc/src/release_notes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ Thick Mode Changes
2525
Common Changes
2626
++++++++++++++
2727

28+
#) Fixed bug when calling :meth:`Cursor.execute()` or
29+
:meth:`Cursor.executemany()` with missing bind data after calling
30+
:meth:`Cursor.setinputsizes()` with at least one of the values supplied as
31+
``None``
32+
(`issue 217 <https://github.com/oracle/python-oracledb/issues/217>`__).
33+
2834

2935
oracledb 1.4.0 (August 2023)
3036
----------------------------

src/oracledb/impl/base/cursor.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ cdef class BaseCursorImpl:
322322
BindVar bind_var
323323
ssize_t i
324324
for i, bind_var in enumerate(self.bind_vars):
325-
bind_var.var_impl._bind(conn, self, num_execs, bind_var.name,
326-
bind_var.pos)
325+
if bind_var is not None and bind_var.var_impl is not None:
326+
bind_var.var_impl._bind(conn, self, num_execs, bind_var.name,
327+
bind_var.pos)
327328

328329
cdef int _reset_bind_vars(self, uint32_t num_rows) except -1:
329330
"""

tests/test_3900_cursor_execute.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,5 +383,13 @@ def type_handler(cursor, metadata):
383383
self.assertEqual(self.cursor.fetchall(),
384384
[(1,), (2,), (3,), (4,), (5,)])
385385

386+
def test_3930_setinputsizes_no_binds(self):
387+
"3930 - test setinputsizes() but without binding"
388+
self.cursor.setinputsizes(None, int)
389+
sql = "select :1, : 2 from dual"
390+
self.assertRaisesRegex(oracledb.DatabaseError,
391+
"^ORA-01008:|^DPY-4010:",
392+
self.cursor.execute, sql, [])
393+
386394
if __name__ == "__main__":
387395
test_env.run_test_cases()

0 commit comments

Comments
 (0)