syntactic changes: rewrite loop with while

This commit is contained in:
Jorge López
2025-01-18 18:47:02 +01:00
parent 07970468bd
commit e4ab2fb273
2 changed files with 12 additions and 11 deletions

View File

@@ -101,17 +101,16 @@ impl Cursor {
// For DDL and DML statements,
// we need to execute the statement immediately
if stmt_is_ddl || stmt_is_dml {
loop {
match stmt.borrow_mut().step().map_err(|e| {
PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e))
})? {
limbo_core::StepResult::IO => {
self.conn.io.run_once().map_err(|e| {
PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e))
})?;
}
_ => break,
}
while stmt
.borrow_mut()
.step()
.map_err(|e| PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e)))?
.eq(&limbo_core::StepResult::IO)
{
self.conn
.io
.run_once()
.map_err(|e| PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e)))?;
}
}

View File

@@ -474,6 +474,7 @@ impl Statement {
}
}
#[derive(PartialEq)]
pub enum StepResult<'a> {
Row(Row<'a>),
IO,
@@ -482,6 +483,7 @@ pub enum StepResult<'a> {
Busy,
}
#[derive(PartialEq)]
pub struct Row<'a> {
pub values: Vec<Value<'a>>,
}