mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-18 17:14:20 +01:00
add smiple test
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user