Skip to content

Commit dc3e16e

Browse files
Fixed bug with the deferral of type assignment when creating variables
for executemany() (#35).
1 parent 501f2fe commit dc3e16e

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ Common Changes
4545
#) The compiler flag ``-arch x86_64`` no longer needs to be explicitly
4646
specified when building from source code on macOS (Intel x86) without
4747
Universal Python binaries.
48+
#) Fixed bug with the deferral of type assignment when creating variables for
49+
:func:`Cursor.executemany()`
50+
(`issue 35 <https://github.com/oracle/python-oracledb/issues/35>`__).
4851
#) Added method :func:`oracledb.is_thin_mode()` to support determining whether
4952
the driver is using thin mode or not
5053
(`issue 16 <https://github.com/oracle/python-oracledb/issues/10>`__).

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)