Raise cx_Oracle.DatabaseError, not IndexError for a scroll operation that
would position the cursor outside of the result set.
This commit is contained in:
parent
0bcbd072a8
commit
73f61d8a07
|
@ -418,8 +418,8 @@ Cursor Object
|
|||
positioned at the first row and if set to "last", the cursor is set to the
|
||||
last row in the result set.
|
||||
|
||||
An IndexError is raised if the mode is "relative" or "absolute" and the
|
||||
scroll operation would position the cursor outside of the result set.
|
||||
An error is raised if the mode is "relative" or "absolute" and the scroll
|
||||
operation would position the cursor outside of the result set.
|
||||
|
||||
.. versionadded:: development
|
||||
|
||||
|
|
|
@ -2197,7 +2197,7 @@ static PyObject *Cursor_Scroll(
|
|||
// handle the case when no rows have been retrieved
|
||||
if (self->bufferRowCount == 0) {
|
||||
if (fetchMode != OCI_FETCH_FIRST && fetchMode != OCI_FETCH_LAST) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
PyErr_SetString(g_DatabaseErrorException,
|
||||
"requested scroll operation would leave result set");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -254,7 +254,8 @@ class TestCursor(BaseTestCase):
|
|||
select NumberCol
|
||||
from TestNumbers
|
||||
order by IntCol""")
|
||||
self.assertRaises(IndexError, cursor.scroll, 12, "absolute")
|
||||
self.assertRaises(cx_Oracle.DatabaseError, cursor.scroll, 12,
|
||||
"absolute")
|
||||
|
||||
def testScrollAbsoluteInBuffer(self):
|
||||
"""test scrolling absolute (when in buffers)"""
|
||||
|
@ -335,7 +336,7 @@ class TestCursor(BaseTestCase):
|
|||
select NumberCol
|
||||
from TestNumbers
|
||||
order by IntCol""")
|
||||
self.assertRaises(IndexError, cursor.scroll, 15)
|
||||
self.assertRaises(cx_Oracle.DatabaseError, cursor.scroll, 15)
|
||||
|
||||
def testScrollRelativeExceptionBefore(self):
|
||||
"""test scrolling relative yields an exception (before result set)"""
|
||||
|
@ -345,7 +346,7 @@ class TestCursor(BaseTestCase):
|
|||
select NumberCol
|
||||
from TestNumbers
|
||||
order by IntCol""")
|
||||
self.assertRaises(IndexError, cursor.scroll, -5)
|
||||
self.assertRaises(cx_Oracle.DatabaseError, cursor.scroll, -5)
|
||||
|
||||
def testScrollRelativeInBuffer(self):
|
||||
"""test scrolling relative (when in buffers)"""
|
||||
|
@ -389,7 +390,8 @@ class TestCursor(BaseTestCase):
|
|||
self.assertEqual(cursor.fetchall(), [])
|
||||
cursor.scroll(mode = "first")
|
||||
self.assertEqual(cursor.fetchall(), [])
|
||||
self.assertRaises(IndexError, cursor.scroll, 1, mode = "absolute")
|
||||
self.assertRaises(cx_Oracle.DatabaseError, cursor.scroll, 1,
|
||||
mode = "absolute")
|
||||
|
||||
def testScrollDifferingArrayAndFetchSizes(self):
|
||||
"""test scrolling with differing array sizes and fetch array sizes"""
|
||||
|
|
Loading…
Reference in New Issue