Fix sqlite3 Cursor.fetchmany to not fetch rows when size=0 (#7425)

This commit is contained in:
Jiseok CHOI authored and GitHub committed 2026-03-14 15:49:55 +09:00
1 parent 257cf6fa0e
commit ccad9c168a
2 files changed
+8 -5

No files matched your search

-1
View File
@@ -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()
+8 -4
View File
@@ -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)