Skip to content

Prepared queries do not pass parameters correctly #2192

@pacman82

Description

@pacman82

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions