feat: initial implementation of Statement::bind

This commit is contained in:
Levy A.
2025-01-14 06:35:02 -03:00
parent b589203fea
commit 08c8c655e9
12 changed files with 241 additions and 6 deletions

View File

@@ -40,7 +40,7 @@ impl TempDatabase {
#[cfg(test)]
mod tests {
use super::*;
use limbo_core::{CheckpointStatus, Connection, StepResult, Value};
use limbo_core::{CheckpointStatus, Connection, Rows, StepResult, Value};
use log::debug;
#[ignore]
@@ -572,4 +572,29 @@ mod tests {
do_flush(&conn, &tmp_db)?;
Ok(())
}
#[test]
fn test_statement_bind() -> anyhow::Result<()> {
let _ = env_logger::try_init();
let tmp_db = TempDatabase::new("CREATE TABLE test (x INTEGER PRIMARY KEY);");
let conn = tmp_db.connect_limbo();
let mut stmt = conn.prepare("select ?")?;
stmt.bind(Value::Text(&"hello".to_string()));
loop {
match stmt.step()? {
StepResult::Row(row) => {
if let Value::Text(s) = row.values[0] {
assert_eq!(s, "hello")
}
}
StepResult::IO => {
tmp_db.io.run_once()?;
}
StepResult::Interrupt => break,
StepResult::Done => break,
StepResult::Busy => panic!("Database is busy"),
};
}
Ok(())
}
}