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:
Jussi Saurio
2025-10-16 14:02:07 +03:00
parent 6f1bda1438
commit 213af28cf3

View File

@@ -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)
}
}