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 @@ -1126,7 +1126,6 @@ def test_fetchmany(self):
res = self.cu.fetchmany(100)
self.assertEqual(res, [])

@unittest.expectedFailure # TODO: RUSTPYTHON fetchmany size validation not implemented
def test_invalid_fetchmany(self):
UINT32_MAX = (1 << 32) - 1
fetchmany = self.cu.fetchmany
Expand Down
13 changes: 10 additions & 3 deletions crates/stdlib/src/_sqlite3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1883,9 +1883,16 @@ mod _sqlite3 {
args: FetchManyArgs,
vm: &VirtualMachine,
) -> PyResult<Vec<PyObjectRef>> {
let max_rows = args
.size
.unwrap_or_else(|| zelf.arraysize.load(Ordering::Relaxed));
let max_rows = match args.size {
Some(size) => {
if size < 0 {
return Err(vm.new_value_error("fetchmany may not be negative"));
}

size
}
None => zelf.arraysize.load(Ordering::Relaxed),
};

let mut list = vec![];
while let PyIterReturn::Return(row) = Cursor::next(zelf, vm)? {
Expand Down
Loading