Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,6 @@ def test_invalid_array_size(self):
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()
Expand Down
12 changes: 8 additions & 4 deletions crates/stdlib/src/_sqlite3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading