Skip to content

Commit

Permalink
If cursor.setinputsizes() is called without any parameters, do not se…
Browse files Browse the repository at this point in the history
…t 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).
  • Loading branch information
anthony-tuininga committed Jul 3, 2018
1 parent 4f85998 commit fee92ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cxoCursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,10 @@ static PyObject *cxoCursor_setInputSizes(cxoCursor *cursor, PyObject *args,
else cursor->bindVariables = PyList_New(numPositionalArgs);
if (!cursor->bindVariables)
return NULL;
cursor->setInputSizes = 1;

// retain bind variables if any were set
if (numKeywordArgs > 0 || numPositionalArgs > 0)
cursor->setInputSizes = 1;

// process each input
if (numKeywordArgs > 0) {
Expand Down
6 changes: 6 additions & 0 deletions test/Cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,12 @@ def testSetInputSizesNegative(self):
self.cursor.setinputsizes, val, x = val)
self.assertRaises(TypeError, self.cursor.setinputsizes, val)

def testSetInputSizesNoParameters(self):
"test setting input sizes without any parameters"
self.cursor.setinputsizes()
self.cursor.execute("select :val from dual", val = "Test Value")
self.assertEqual(self.cursor.fetchall(), [("Test Value",)])

def testSetInputSizesByPosition(self):
"""test setting input sizes with positional args"""
var = self.cursor.var(cx_Oracle.STRING, 100)
Expand Down

0 comments on commit fee92ab

Please sign in to comment.