add smiple test

This commit is contained in:
Nikita Sivukhin
2025-09-30 13:56:03 +04:00
parent 1b991156f3
commit 264cfdd1c0

View File

@@ -827,3 +827,55 @@ fn test_offset_limit_bind() -> anyhow::Result<()> {
Ok(())
}
#[test]
fn test_upsert_parameters_order() -> anyhow::Result<()> {
let tmp_db = TempDatabase::new_with_rusqlite(
"CREATE TABLE test (k INTEGER PRIMARY KEY, v INTEGER);",
false,
);
let conn = tmp_db.connect_limbo();
conn.execute("INSERT INTO test VALUES (1, 2), (3, 4)")?;
let mut stmt =
conn.prepare("INSERT INTO test VALUES (?, ?), (?, ?) ON CONFLICT DO UPDATE SET v = ?")?;
stmt.bind_at(1.try_into()?, Value::Integer(1));
stmt.bind_at(2.try_into()?, Value::Integer(20));
stmt.bind_at(3.try_into()?, Value::Integer(3));
stmt.bind_at(4.try_into()?, Value::Integer(40));
stmt.bind_at(5.try_into()?, Value::Integer(66));
loop {
match stmt.step()? {
StepResult::Row | StepResult::IO => stmt.run_once()?,
_ => break,
}
}
let mut rows = Vec::new();
let mut stmt = conn.prepare("SELECT * FROM test")?;
loop {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
rows.push(row.get_values().cloned().collect::<Vec<_>>());
}
StepResult::IO => stmt.run_once()?,
_ => break,
}
}
assert_eq!(
rows,
vec![
vec![
turso_core::Value::Integer(1),
turso_core::Value::Integer(66)
],
vec![
turso_core::Value::Integer(3),
turso_core::Value::Integer(66)
]
]
);
Ok(())
}