Skip to content

no error on multiple statements within one query #2244

@CharaVerKys

Description

@CharaVerKys
--------------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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions