Skip to content

Commit 072bd9b

Browse files
committed
changed libsql to use transactions if needed
1 parent 7b67e65 commit 072bd9b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/lib/database_drivers/libsql.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl DatabaseDriver for LibSQLDriver {
4444
fn execute<'a>(
4545
&'a mut self,
4646
query: &'a str,
47-
_run_in_transaction: bool,
47+
run_in_transaction: bool,
4848
) -> Pin<Box<dyn Future<Output = Result<(), anyhow::Error>> + '_>> {
4949
let fut = async move {
5050
let queries = query
@@ -53,7 +53,18 @@ impl DatabaseDriver for LibSQLDriver {
5353
.map(Statement::new)
5454
.collect::<Vec<Statement>>();
5555

56-
self.db.batch(queries).await?;
56+
if run_in_transaction {
57+
self.db.batch(queries).await?;
58+
} else {
59+
for query in queries {
60+
match self.db.execute(query).await {
61+
Ok(_) => {}
62+
Err(e) => {
63+
bail!("{:?}", e);
64+
}
65+
}
66+
}
67+
}
5768

5869
Ok(())
5970
};

0 commit comments

Comments
 (0)