libsql icon indicating copy to clipboard operation
libsql copied to clipboard

Prepared queries do not pass parameters correctly

Open pacman82 opened this issue 1 month ago • 2 comments

A reproducing example:

use libsql::Builder;

#[tokio::main]
async fn main() {
    let database = Builder::new_local(":memory:").build().await.unwrap();
    let connection = database.connect().unwrap();
    connection
        .execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)", ())
        .await
        .unwrap();
    let insert_user = connection
        .prepare("INSERT INTO users (id, name) VALUES (?,?)")
        .await
        .unwrap();

    insert_user.execute((1, "John Doe")).await.unwrap();
    insert_user.execute((2, "Jane Doe")).await.unwrap(); // Error: UNIQUE constraint failed: users.id
}

If removing the unique constraint, and querying the table, one can also see, that the second insert statement indeed inserts using a 1 for the id.

pacman82 avatar Nov 12 '25 09:11 pacman82