Skip to content

Commit fee92ab

Browse files
If cursor.setinputsizes() is called without any parameters, do not set the flag
indicating that bind variables should be returned since otherwise binding with named arguments will raise the error "cx_Oracle.ProgrammingError: positional and named binds cannot be intermixed" (#199).
1 parent 4f85998 commit fee92ab

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/cxoCursor.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,10 @@ static PyObject *cxoCursor_setInputSizes(cxoCursor *cursor, PyObject *args,
17391739
else cursor->bindVariables = PyList_New(numPositionalArgs);
17401740
if (!cursor->bindVariables)
17411741
return NULL;
1742-
cursor->setInputSizes = 1;
1742+
1743+
// retain bind variables if any were set
1744+
if (numKeywordArgs > 0 || numPositionalArgs > 0)
1745+
cursor->setInputSizes = 1;
17431746

17441747
// process each input
17451748
if (numKeywordArgs > 0) {

test/Cursor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ def testSetInputSizesNegative(self):
509509
self.cursor.setinputsizes, val, x = val)
510510
self.assertRaises(TypeError, self.cursor.setinputsizes, val)
511511

512+
def testSetInputSizesNoParameters(self):
513+
"test setting input sizes without any parameters"
514+
self.cursor.setinputsizes()
515+
self.cursor.execute("select :val from dual", val = "Test Value")
516+
self.assertEqual(self.cursor.fetchall(), [("Test Value",)])
517+
512518
def testSetInputSizesByPosition(self):
513519
"""test setting input sizes with positional args"""
514520
var = self.cursor.var(cx_Oracle.STRING, 100)

0 commit comments

Comments
 (0)