Skip to content

Commit 1fd7940

Browse files
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).
1 parent 592735f commit 1fd7940

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/cxoVarType.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ cxoVarType *cxoVarType_fromPythonType(PyTypeObject *type)
205205
static Py_ssize_t cxoVarType_calculateSize(PyObject *value,
206206
cxoTransformNum transformNum)
207207
{
208+
Py_ssize_t size = 0;
208209
#if PY_MAJOR_VERSION < 3
209210
const void *ptr;
210-
Py_ssize_t size = 0;
211211
#endif
212212

213213
switch (transformNum) {
@@ -221,13 +221,15 @@ static Py_ssize_t cxoVarType_calculateSize(PyObject *value,
221221
return size;
222222
#endif
223223
case CXO_TRANSFORM_NSTRING:
224-
return PyUnicode_GET_SIZE(value);
224+
size = PyUnicode_GET_SIZE(value);
225+
return (size == 0) ? 1 : size;
225226
case CXO_TRANSFORM_STRING:
226227
#if PY_MAJOR_VERSION >= 3
227-
return PyUnicode_GET_SIZE(value);
228+
size = PyUnicode_GET_SIZE(value);
228229
#else
229-
return PyString_GET_SIZE(value);
230+
size = PyString_GET_SIZE(value);
230231
#endif
232+
return (size == 0) ? 1 : size;
231233
default:
232234
break;
233235
}

0 commit comments

Comments
 (0)