-
Notifications
You must be signed in to change notification settings - Fork 423
Open
Description
When calling Connection::prepare
once and using the Statement
to execute multiple times with varying parameters it causes the query to be executed with the first bound parameters.
Minimal reproduction example:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let database = libsql::Builder::new_local("example.db").build().await?;
let conn = database.connect()?;
conn.execute_batch("CREATE TABLE domain (fqdn TEXT NOT NULL PRIMARY KEY)").await?;
let mut stmt = conn.prepare("INSERT INTO domain VALUES (?1)").await?;
for domain in ["example.com", "example.org"] {
println!("{}", domain);
stmt.execute([domain]).await?;
}
Ok(())
}
Output:
example.com
example.org
Error: SqliteFailure(1555, "UNIQUE constraint failed: domain.fqdn")
I just released the first version of deadpool-libsql and ran into this issue in my first application I'm trying to build with libsql.
When moving the Connection::prepare
call inside the loop it does the right thing. But that's really not how I would expect prepared statements to work.
Metadata
Metadata
Assignees
Labels
No labels