mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-30 06:24:21 +01:00
feat: initial implementation of Statement::bind
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user