tursodatabase / tursodatabase/libsql
no error on multiple statements within one query
Open
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
--------------charaverk | ~/repos/libsql_execute/src ~$ cat ../Cargo.toml
[package]
name = "libsql_execute"
version = "0.1.0"
edition = "2024"
[dependencies]
libsql = { version = "0.9.30", default-features = false, features = ["core"] }
tokio = { version = "1.52.*", features = ["full"] }
------------charaverk | ~/repos/libsql_execute/src ~$ cat main.rs
fn main() {
let runtime = tokio::runtime::Runtime::new().unwrap();
runtime.block_on(async{
let db = libsql::Builder::new_local("/tmp/test.db").build().await.unwrap();
let conn = db.connect().unwrap();
//? works as expected
conn.execute("CREATE TABLE IF NOT EXISTS test_table(id INTEGER PRIMARY KEY, data INTEGER)", ()).await.unwrap();
//? this return ok, but should return error
let res = conn.execute(
"INSERT OR IGNORE INTO test_table(id, data) VALUES(?1, 0);
UPDATE test_table SET data = data + 1 WHERE id == ?1;
", [ 1 ]).await;
assert!(res.is_ok(), "not ok on two statements");
assert!(res.unwrap() == 1, "affected not_eq 1 lines");
//? and value here is 0; but expect 1 since last statement not returned error
let mut res = conn.query(
"SELECT data FROM test_table WHERE id == ?1;
", [ 1 ]).await.unwrap();
let data = res.next().await.unwrap().unwrap().get_value(0).unwrap().as_integer().unwrap().clone();
assert_eq!(data, 1); //* panic
});
}
expected behavior: error about multiple statements in query
rustsql do this
this is silent critical logic error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproduction shown in main.rs with the dependency versions in Cargo.toml, then inspect how conn.execute handles the SQL string containing INSERT and UPDATE statements. Done means the multiple-statement call returns an error instead of silently reporting success; verify the behavior with the provided assertions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100