mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Fix sqlite3 Cursor.fetchmany to not fetch rows when size=0 (#7425)
This commit is contained in:
1 parent
e7d2b57dcc
commit
430eb5ffe4
2 files changed
+8
-5
No files matched your search
Vendored
-1
@@ -1096,7 +1096,6 @@ class CursorTests(unittest.TestCase):
|
||||
self.assertRaises(ValueError, setter, -3)
|
||||
self.assertRaises(OverflowError, setter, UINT32_MAX + 1)
|
||||
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON fetchmany behavior with exhausted cursor differs
|
||||
def test_fetchmany(self):
|
||||
# no active SQL statement
|
||||
res = self.cu.fetchmany()
|
||||
|
||||
@@ -1900,10 +1900,14 @@ mod _sqlite3 {
|
||||
};
|
||||
|
||||
let mut list = vec![];
|
||||
while let PyIterReturn::Return(row) = Cursor::next(zelf, vm)? {
|
||||
list.push(row);
|
||||
if max_rows > 0 && list.len() as c_int >= max_rows {
|
||||
break;
|
||||
let mut remaining = max_rows;
|
||||
while remaining > 0 {
|
||||
match Cursor::next(zelf, vm)? {
|
||||
PyIterReturn::Return(row) => {
|
||||
list.push(row);
|
||||
remaining -= 1;
|
||||
}
|
||||
PyIterReturn::StopIteration(_) => break,
|
||||
}
|
||||
}
|
||||
Ok(list)
|
||||
|
||||
Reference in new issue
Block a user