tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.

Home Page:https://turso.tech/libsql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

conn.changes() always returns 0 on remote connection.

wyhaya opened this issue · comments

let conn = Builder::new_remote("http://localhost:8867".into(), "".into())...;
conn.execute_batch(r#"CREATE TABLE IF NOT EXISTS example (id INTEGER NOT NULL PRIMARY KEY);"#)...;

conn.query(r#"INSERT INTO example DEFAULT VALUES RETURNING *;"#, ())
        .await
        .unwrap();
// Error
assert_eq!(conn.changes(), 1); 

// or

let mut stam = conn
        .prepare(r#"INSERT INTO example DEFAULT VALUES RETURNING *;"#)
        .await
        .unwrap();
stam.query(()).await.unwrap();
// Error
assert_eq!(conn.changes(), 1);
assertion `left == right` failed
  left: 0
 right: 1

It seems that only the query method of the remote connection has an issue; there are no problems whatsoever when using a local connection.

I thing using execute instead of query should solve the problem.

@haaawk I wish to obtain columns, rows, and affected_row_count simultaneously, so I have to call the 'query' function.