Skip to content

Commit 4c86e20

Browse files
Fixed bug with the deferral of type assignment when creating variables
for executemany() (#35).
1 parent 213d535 commit 4c86e20

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Thin Mode Changes
1616
Common Changes
1717
++++++++++++++
1818

19+
#) Fixed bug with the deferral of type assignment when creating variables for
20+
:func:`Cursor.executemany()`
21+
(`issue 35 <https://github.com/oracle/python-oracledb/issues/35>`__).
22+
1923

2024
oracledb 1.0.2 (July 2022)
2125
--------------------------

src/oracledb/impl/base/cursor.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ cdef class BaseCursorImpl:
335335
num_rows = len(parameters)
336336
self._reset_bind_vars(num_rows)
337337
for i, params_row in enumerate(parameters):
338-
defer_type_assignment = (i == num_rows - 1)
338+
defer_type_assignment = (i < num_rows - 1)
339339
self._bind_values(cursor, type_handler, params_row, num_rows, i,
340340
defer_type_assignment)
341341

tests/test_4000_cursor_executemany.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,5 +294,21 @@ def test_4020_executemany_with_plsql_single_row(self):
294294
self.cursor.executemany("begin :1 := :2; end;", data)
295295
self.assertEqual(var.values, [value])
296296

297+
def test_4021_defer_type_assignment(self):
298+
"4021 - test deferral of type assignment"
299+
self.cursor.execute("truncate table TestTempTable")
300+
data = [(1, None), (2, 25)]
301+
self.cursor.executemany("""
302+
insert into TestTempTable
303+
(IntCol, NumberCol)
304+
values (:1, :2)""", data)
305+
self.connection.commit()
306+
self.cursor.execute("""
307+
select IntCol, NumberCol
308+
from TestTempTable
309+
order by IntCol""")
310+
fetched_data = self.cursor.fetchall()
311+
self.assertEqual(data, fetched_data)
312+
297313
if __name__ == "__main__":
298314
test_env.run_test_cases()

0 commit comments

Comments
 (0)