mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-31 13:54:27 +01:00
rust bindings: make Statement::query:row() finish execution
otherwise the statement will be considered to be in progress, and its Drop implementation will roll back the transaction it is in.
This commit is contained in:
@@ -596,7 +596,11 @@ impl Statement {
|
||||
pub async fn query_row(&mut self, params: impl IntoParams) -> Result<Row> {
|
||||
let mut rows = self.query(params).await?;
|
||||
|
||||
rows.next().await?.ok_or(Error::QueryReturnedNoRows)
|
||||
let first_row = rows.next().await?.ok_or(Error::QueryReturnedNoRows)?;
|
||||
// Discard remaining rows so that the statement is executed to completion
|
||||
// Otherwise Drop of the statement will cause transaction rollback
|
||||
while rows.next().await?.is_some() {}
|
||||
Ok(first_row)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user