Skip to content

Commit 983dfda

Browse files
Adjust return value of cursor.callproc() to follow documentation so that only
positional arguments are returned (#287).
1 parent 511cd7a commit 983dfda

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/cxoCursor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,8 +1326,8 @@ static PyObject *cxoCursor_callProc(cxoCursor *cursor, PyObject *args,
13261326
keywordArguments) < 0)
13271327
return NULL;
13281328

1329-
// create the return value
1330-
numArgs = PyList_GET_SIZE(cursor->bindVariables);
1329+
// create the return value (only positional arguments are returned)
1330+
numArgs = (listOfArguments) ? PySequence_Size(listOfArguments) : 0;
13311331
results = PyList_New(numArgs);
13321332
if (!results)
13331333
return NULL;

test/Cursor.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,30 @@ def testCallProc(self):
8686
results = self.cursor.callproc("proc_Test", ("hi", 5, var))
8787
self.assertEqual(results, ["hi", 10, 2.0])
8888

89+
def testCallProcAllKeywords(self):
90+
"test executing a stored procedure with args in keywordParameters"
91+
kwargs = dict(a_InOutValue=self.cursor.var(cx_Oracle.NUMBER),
92+
a_InValue="hi", a_OutValue=self.cursor.var(cx_Oracle.NUMBER))
93+
kwargs['a_InOutValue'].setvalue(0, 5)
94+
results = self.cursor.callproc("proc_Test", keywordParameters=kwargs)
95+
self.assertEqual(results, [])
96+
self.assertEqual(kwargs['a_InOutValue'].getvalue(), 10)
97+
self.assertEqual(kwargs['a_OutValue'].getvalue(), 2.0)
98+
99+
def testCallProcOnlyLastKeyword(self):
100+
"test executing a stored procedure with last arg in keywordParameters"
101+
kwargs = dict(a_OutValue = self.cursor.var(cx_Oracle.NUMBER))
102+
results = self.cursor.callproc("proc_Test", ("hi", 5), kwargs)
103+
self.assertEqual(results, ["hi", 10])
104+
self.assertEqual(kwargs['a_OutValue'].getvalue(), 2.0)
105+
106+
def testCallProcRepeatedKeywordParameters(self):
107+
"test executing a stored procedure, repeated arg in keywordParameters"
108+
kwargs = dict(a_InValue="hi",
109+
a_OutValue=self.cursor.var(cx_Oracle.NUMBER))
110+
self.assertRaises(cx_Oracle.DatabaseError, self.cursor.callproc,
111+
"proc_Test", parameters=("hi", 5), keywordParameters=kwargs)
112+
89113
def testCallProcNoArgs(self):
90114
"""test executing a stored procedure without any arguments"""
91115
results = self.cursor.callproc(u"proc_TestNoArgs")

0 commit comments

Comments
 (0)