Skip to content

Commit

Permalink
Fix triggering a panic in the sqlite row cursor implementation
Browse files Browse the repository at this point in the history
See diesel-rs/diesel#4115 for a fix of the
underlying issue in diesel itself
  • Loading branch information
weiznich committed Jul 12, 2024
1 parent 3844fb3 commit a5342a9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/sync_connection_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,17 @@ where
let mut cache = <<<C as LoadConnection>::Row<'_, '_> as IntoOwnedRow<
<C as Connection>::Backend,
>>::Cache as Default>::default();
conn.load(&query).map(|c| {
c.map(|row| row.map(|r| IntoOwnedRow::into_owned(r, &mut cache)))
.collect::<Vec<QueryResult<O>>>()
})
let cursor = conn.load(&query)?;

let size_hint = cursor.size_hint();
let mut out = Vec::with_capacity(size_hint.1.unwrap_or(size_hint.0));
// we use an explicit loop here to easily propagate possible errors
// as early as possible
for row in cursor {
out.push(Ok(IntoOwnedRow::into_owned(row?, &mut cache)));
}

Ok(out)
})
.map_ok(|rows| futures_util::stream::iter(rows).boxed())
.boxed()
Expand Down

0 comments on commit a5342a9

Please sign in to comment.