Skip to content

Commit 85c4af9

Browse files
Added additional test to verify case when a DML returning statement returns
multiple rows during one execute but in the subsequent execute it returns no rows.
1 parent a79dcb2 commit 85c4af9

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

test/DMLReturning.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,11 @@ def testUpdateMultipleRows(self):
158158

159159
def testUpdateMultipleRowsExecuteMany(self):
160160
"test update multiple rows with DML returning (executeMany)"
161+
data = [(i, "The initial value of string %d" % i) \
162+
for i in range(1, 11)]
161163
self.cursor.execute("truncate table TestTempTable")
162-
for i in range(1, 11):
163-
self.cursor.execute("insert into TestTempTable values (:1, :2)",
164-
(i, "The initial value of string %d" % i))
164+
self.cursor.executemany("insert into TestTempTable values (:1, :2)",
165+
data)
165166
intVar = self.cursor.var(cx_Oracle.NUMBER, arraysize = 3)
166167
strVar = self.cursor.var(str, arraysize = 3)
167168
self.cursor.setinputsizes(None, intVar, strVar)
@@ -238,3 +239,18 @@ def testDeleteReturningDecreasingRowsReturned(self):
238239
results.append(intVar.values)
239240
self.assertEqual(results, [ [1, 2, 3, 4], [5, 6, 7], [8, 9] ])
240241

242+
def testDeleteReturningNoRowsAfterManyRows(self):
243+
"test delete returning no rows after initially returning many rows"
244+
data = [(i, "Test String %d" % i) for i in range(1, 11)]
245+
self.cursor.execute("truncate table TestTempTable")
246+
self.cursor.executemany("insert into TestTempTable values (:1, :2)",
247+
data)
248+
intVar = self.cursor.var(int)
249+
self.cursor.execute("""
250+
delete from TestTempTable
251+
where IntCol < :1
252+
returning IntCol into :2""", [5, intVar])
253+
self.assertEqual(intVar.values, [1, 2, 3, 4])
254+
self.cursor.execute(None, [4, intVar])
255+
self.assertEqual(intVar.values, [])
256+

0 commit comments

Comments
 (0)