Skip to content

Commit a79dcb2

Browse files
Ensure that behavior in cx_Oracle 6.3 with __future__.dml_ret_array_val not set
or False is the same as the behavior in cx_Oracle 6.2 (#176).
1 parent 2ea4be0 commit a79dcb2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/cxoVar.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,14 @@ PyObject *cxoVar_getSingleValue(cxoVar *var, dpiData *data, uint32_t arrayPos)
443443
if (dpiVar_getReturnedData(var->handle, 0, &numReturnedRows,
444444
&data) < 0)
445445
return cxoError_raiseAndReturnNull();
446-
if (arrayPos >= numReturnedRows) {
446+
if (arrayPos >= var->allocatedElements &&
447+
arrayPos >= numReturnedRows) {
447448
PyErr_SetString(PyExc_IndexError,
448449
"cxoVar_getSingleValue: array size exceeded");
449450
return NULL;
450451
}
452+
if (arrayPos >= numReturnedRows)
453+
data = var->data;
451454
}
452455

453456
// in all other cases, just get the value stored at specified position
@@ -497,7 +500,7 @@ PyObject *cxoVar_getValue(cxoVar *var, uint32_t arrayPos)
497500
return cxoError_raiseAndReturnNull();
498501
return cxoVar_getArrayValue(var, numElements, var->data);
499502
}
500-
if (arrayPos >= var->allocatedElements) {
503+
if (arrayPos >= var->allocatedElements && !var->getReturnedData) {
501504
PyErr_SetString(PyExc_IndexError,
502505
"cxoVar_getSingleValue: array size exceeded");
503506
return NULL;

test/DMLReturning.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def testUpdateNoRows(self):
112112
strVar = strVar)
113113
self.assertEqual(intVar.values, [])
114114
self.assertEqual(strVar.values, [])
115+
self.assertEqual(intVar.getvalue(), None)
116+
self.assertEqual(strVar.getvalue(), None)
115117
cx_Oracle.__future__.dml_ret_array_val = True
116118
try:
117119
self.assertEqual(intVar.values, [[]])
@@ -141,6 +143,8 @@ def testUpdateMultipleRows(self):
141143
"The final value of string 9",
142144
"The final value of string 10"
143145
])
146+
self.assertEqual(intVar.getvalue(1), 24)
147+
self.assertEqual(strVar.getvalue(2), "The final value of string 10")
144148
cx_Oracle.__future__.dml_ret_array_val = True
145149
try:
146150
self.assertEqual(intVar.values, [[23, 24, 25]])

0 commit comments

Comments
 (0)