From 3b9c98d979e577d758d5af919b4d21f7a1c30b2f Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 30 Sep 2020 18:24:38 +0200 Subject: [PATCH] Fix bounds for F on query::Map Query::map was not usable before. --- sqlx-core/src/query.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sqlx-core/src/query.rs b/sqlx-core/src/query.rs index a6d02184..a2910454 100644 --- a/sqlx-core/src/query.rs +++ b/sqlx-core/src/query.rs @@ -251,7 +251,7 @@ where impl<'q, DB, F, O, A> Map<'q, DB, F, A> where DB: Database, - F: Send + Sync + Fn(DB::Row) -> Result, + F: TryMapRow, O: Send + Unpin, A: 'q + Send + IntoArguments<'q, DB>, { @@ -277,7 +277,7 @@ where /// Execute multiple queries and return the generated results as a stream /// from each query, in a stream. pub fn fetch_many<'e, 'c: 'e, E>( - self, + mut self, executor: E, ) -> BoxStream<'e, Result, Error>> where @@ -294,7 +294,7 @@ where r#yield!(match v { Either::Left(v) => Either::Left(v), Either::Right(row) => { - Either::Right((self.mapper)(row)?) + Either::Right(self.mapper.try_map_row(row)?) } }); } @@ -333,7 +333,7 @@ where } /// Execute the query and returns at most one row. - pub async fn fetch_optional<'e, 'c: 'e, E>(self, executor: E) -> Result, Error> + pub async fn fetch_optional<'e, 'c: 'e, E>(mut self, executor: E) -> Result, Error> where 'q: 'e, E: 'e + Executor<'c, Database = DB>, @@ -344,7 +344,7 @@ where let row = executor.fetch_optional(self.inner).await?; if let Some(row) = row { - (self.mapper)(row).map(Some) + self.mapper.try_map_row(row).map(Some) } else { Ok(None) }