Ensure that error ORA-24816: Expanded non LONG bind data supplied after actual

LONG or LOB column" is not raised by ensuring an empty string does not use a
size of zero (which triggers this situation in Oracle 12.1).
This commit is contained in:
Anthony Tuininga 2018-03-05 13:37:32 -07:00
parent 592735f104
commit 1fd7940494

View File

@ -205,9 +205,9 @@ cxoVarType *cxoVarType_fromPythonType(PyTypeObject *type)
static Py_ssize_t cxoVarType_calculateSize(PyObject *value,
cxoTransformNum transformNum)
{
Py_ssize_t size = 0;
#if PY_MAJOR_VERSION < 3
const void *ptr;
Py_ssize_t size = 0;
#endif
switch (transformNum) {
@ -221,13 +221,15 @@ static Py_ssize_t cxoVarType_calculateSize(PyObject *value,
return size;
#endif
case CXO_TRANSFORM_NSTRING:
return PyUnicode_GET_SIZE(value);
size = PyUnicode_GET_SIZE(value);
return (size == 0) ? 1 : size;
case CXO_TRANSFORM_STRING:
#if PY_MAJOR_VERSION >= 3
return PyUnicode_GET_SIZE(value);
size = PyUnicode_GET_SIZE(value);
#else
return PyString_GET_SIZE(value);
size = PyString_GET_SIZE(value);
#endif
return (size == 0) ? 1 : size;
default:
break;
}