Correct support for executemany() when strings that are found later in the
array are larger than strings found earlier in the array.
This commit is contained in:
parent
7e29e743ab
commit
c946e86384
|
@ -263,9 +263,10 @@ static void Variable_Free(udt_Variable *self)
|
|||
static int Variable_SetValueBytes(udt_Variable *var, uint32_t pos,
|
||||
dpiData *data, PyObject *value)
|
||||
{
|
||||
dpiData *tempVarData, *sourceData;
|
||||
dpiVar *tempVarHandle;
|
||||
dpiData *tempVarData;
|
||||
udt_Buffer buffer;
|
||||
uint32_t i;
|
||||
int status;
|
||||
|
||||
if (cxBuffer_FromObject(&buffer, value,
|
||||
|
@ -279,9 +280,22 @@ static int Variable_SetValueBytes(udt_Variable *var, uint32_t pos,
|
|||
cxBuffer_Clear(&buffer);
|
||||
return Error_RaiseAndReturnInt();
|
||||
}
|
||||
for (i = 0; i < var->allocatedElements; i++) {
|
||||
sourceData = &var->data[i];
|
||||
if (i == pos || sourceData->isNull)
|
||||
continue;
|
||||
if (dpiVar_setFromBytes(tempVarHandle, i,
|
||||
sourceData->value.asBytes.ptr,
|
||||
sourceData->value.asBytes.length) < 0) {
|
||||
cxBuffer_Clear(&buffer);
|
||||
dpiVar_release(tempVarHandle);
|
||||
return Error_RaiseAndReturnInt();
|
||||
}
|
||||
}
|
||||
dpiVar_release(var->handle);
|
||||
var->handle = tempVarHandle;
|
||||
var->data = tempVarData;
|
||||
var->bufferSize = buffer.size;
|
||||
}
|
||||
status = dpiVar_setFromBytes(var->handle, pos, buffer.ptr, buffer.size);
|
||||
cxBuffer_Clear(&buffer);
|
||||
|
|
|
@ -154,17 +154,15 @@ class TestCursor(BaseTestCase):
|
|||
( 4, "Fourth" ),
|
||||
( 5, "Fifth" ),
|
||||
( 6, "Sixth" ),
|
||||
( 7, "Seventh" ) ]
|
||||
self.cursor.bindarraysize = 5
|
||||
self.cursor.setinputsizes(int, 100)
|
||||
( 7, "Seventh and the longest one" ) ]
|
||||
sql = "insert into TestTempTable (IntCol, StringCol) values (:1, :2)"
|
||||
self.cursor.executemany(sql, rows)
|
||||
var = self.cursor.bindvars[1]
|
||||
self.cursor.execute("select count(*) from TestTempTable")
|
||||
count, = self.cursor.fetchone()
|
||||
self.assertEqual(count, len(rows))
|
||||
self.assertEqual(var.bufferSize,
|
||||
100 * self.connection.maxBytesPerCharacter)
|
||||
self.cursor.execute("""
|
||||
select IntCol, StringCol
|
||||
from TestTempTable
|
||||
order by IntCol""")
|
||||
fetchedRows = self.cursor.fetchall()
|
||||
self.assertEqual(fetchedRows, rows)
|
||||
|
||||
def testExecuteManyWithExecption(self):
|
||||
"""test executing a statement multiple times (with exception)"""
|
||||
|
|
Loading…
Reference in New Issue