From 69ff54402e8ebf8fc690ce0d898e67cd897d4592 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 2 Dec 2022 15:40:28 +0100 Subject: [PATCH] Remove GAT workarounds --- src/lib.rs | 44 +++--- src/mysql/mod.rs | 31 ++--- src/pg/mod.rs | 27 ++-- src/pooled_connection/deadpool.rs | 2 +- src/pooled_connection/mod.rs | 37 +++-- src/run_query_dsl/mod.rs | 219 +++++++++++------------------- src/stmt_cache.rs | 4 +- src/transaction_manager.rs | 6 +- 8 files changed, 138 insertions(+), 232 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 92a8a3a..7e94cf6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -111,31 +111,30 @@ pub trait SimpleAsyncConnection { async fn batch_execute(&mut self, query: &str) -> QueryResult<()>; } -/// This trait is a workaround to emulate GAT on stable rust -/// -/// It is used to specify the return type of `AsyncConnection::load` -/// and `AsyncConnection::execute` which may contain lifetimes -pub trait AsyncConnectionGatWorkaround<'conn, 'query, DB: Backend> { - /// The future returned by `AsyncConnection::execute` - type ExecuteFuture: Future> + Send; - /// The future returned by `AsyncConnection::load` - type LoadFuture: Future> + Send; - /// The inner stream returned by `AsyncConnection::load` - type Stream: Stream> + Send; - /// The row type used by the stream returned by `AsyncConnection::load` - type Row: Row<'conn, DB>; -} - /// An async connection to a database /// /// This trait represents a n async database connection. It can be used to query the database through /// the query dsl provided by diesel, custom extensions or raw sql queries. It essentially mirrors /// the sync diesel [`Connection`](diesel::connection::Connection) implementation #[async_trait::async_trait] -pub trait AsyncConnection: SimpleAsyncConnection + Sized + Send -where - for<'a, 'b> Self: AsyncConnectionGatWorkaround<'a, 'b, Self::Backend>, -{ +pub trait AsyncConnection: SimpleAsyncConnection + Sized + Send { + /// The future returned by `AsyncConnection::execute` + type ExecuteFuture<'conn, 'query>: Future> + Send + where + Self: 'conn; + /// The future returned by `AsyncConnection::load` + type LoadFuture<'conn, 'query>: Future>> + Send + where + Self: 'conn; + /// The inner stream returned by `AsyncConnection::load` + type Stream<'conn, 'query>: Stream>> + Send + where + Self: 'conn; + /// The row type used by the stream returned by `AsyncConnection::load` + type Row<'conn, 'query>: Row<'conn, Self::Backend> + where + Self: 'conn; + /// The backend this type connects to type Backend: Backend; @@ -256,10 +255,7 @@ where } #[doc(hidden)] - fn load<'conn, 'query, T>( - &'conn mut self, - source: T, - ) -> >::LoadFuture + fn load<'conn, 'query, T>(&'conn mut self, source: T) -> Self::LoadFuture<'conn, 'query> where T: AsQuery + Send + 'query, T::Query: QueryFragment + QueryId + Send + 'query; @@ -268,7 +264,7 @@ where fn execute_returning_count<'conn, 'query, T>( &'conn mut self, source: T, - ) -> >::ExecuteFuture + ) -> Self::ExecuteFuture<'conn, 'query> where T: QueryFragment + QueryId + Send + 'query; diff --git a/src/mysql/mod.rs b/src/mysql/mod.rs index d5206bf..babd9fa 100644 --- a/src/mysql/mod.rs +++ b/src/mysql/mod.rs @@ -1,7 +1,5 @@ use crate::stmt_cache::{PrepareCallback, StmtCache}; -use crate::{ - AnsiTransactionManager, AsyncConnection, AsyncConnectionGatWorkaround, SimpleAsyncConnection, -}; +use crate::{AnsiTransactionManager, AsyncConnection, SimpleAsyncConnection}; use diesel::connection::statement_cache::MaybeCached; use diesel::mysql::{Mysql, MysqlType}; use diesel::query_builder::{bind_collector::RawBytesBindCollector, QueryFragment, QueryId}; @@ -36,16 +34,7 @@ impl SimpleAsyncConnection for AsyncMysqlConnection { } } -impl<'conn, 'query> AsyncConnectionGatWorkaround<'conn, 'query, Mysql> for AsyncMysqlConnection { - type ExecuteFuture = BoxFuture<'conn, QueryResult>; - type LoadFuture = BoxFuture<'conn, QueryResult>; - type Stream = BoxStream<'conn, QueryResult>; - - type Row = MysqlRow; -} - -const CONNECTION_SETUP_QUERIES: &'static [&'static str] = &[ - "SET sql_mode=(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT'))", +const CONNECTION_SETUP_QUERIES: &[&str] = &[ "SET time_zone = '+00:00';", "SET character_set_client = 'utf8mb4'", "SET character_set_connection = 'utf8mb4'", @@ -54,6 +43,10 @@ const CONNECTION_SETUP_QUERIES: &'static [&'static str] = &[ #[async_trait::async_trait] impl AsyncConnection for AsyncMysqlConnection { + type ExecuteFuture<'conn, 'query> = BoxFuture<'conn, QueryResult>; + type LoadFuture<'conn, 'query> = BoxFuture<'conn, QueryResult>>; + type Stream<'conn, 'query> = BoxStream<'conn, QueryResult>>; + type Row<'conn, 'query> = MysqlRow; type Backend = Mysql; type TransactionManager = AnsiTransactionManager; @@ -74,10 +67,7 @@ impl AsyncConnection for AsyncMysqlConnection { }) } - fn load<'conn, 'query, T>( - &'conn mut self, - source: T, - ) -> >::LoadFuture + fn load<'conn, 'query, T>(&'conn mut self, source: T) -> Self::LoadFuture<'conn, 'query> where T: diesel::query_builder::AsQuery + Send, T::Query: diesel::query_builder::QueryFragment @@ -133,7 +123,7 @@ impl AsyncConnection for AsyncMysqlConnection { fn execute_returning_count<'conn, 'query, T>( &'conn mut self, source: T, - ) -> >::ExecuteFuture + ) -> Self::ExecuteFuture<'conn, 'query> where T: diesel::query_builder::QueryFragment + diesel::query_builder::QueryId @@ -248,11 +238,10 @@ impl AsyncMysqlConnection { let stmt = stmt_cache.cached_prepared_statement(query, &metadata, conn, &Mysql); stmt.and_then(|(stmt, conn)| async move { - let res = update_transaction_manager_status( + update_transaction_manager_status( callback(conn, stmt, ToSqlHelper { metadata, binds }).await, transaction_manager, - ); - res + ) }) .boxed() } diff --git a/src/pg/mod.rs b/src/pg/mod.rs index 934a75d..a5da841 100644 --- a/src/pg/mod.rs +++ b/src/pg/mod.rs @@ -8,9 +8,7 @@ use self::error_helper::ErrorHelper; use self::row::PgRow; use self::serialize::ToSqlHelper; use crate::stmt_cache::{PrepareCallback, StmtCache}; -use crate::{ - AnsiTransactionManager, AsyncConnection, AsyncConnectionGatWorkaround, SimpleAsyncConnection, -}; +use crate::{AnsiTransactionManager, AsyncConnection, SimpleAsyncConnection}; use diesel::connection::statement_cache::PrepareForCache; use diesel::pg::{ FailedToLookupTypeError, PgMetadataCache, PgMetadataCacheKey, PgMetadataLookup, PgTypeMetadata, @@ -110,18 +108,12 @@ impl SimpleAsyncConnection for AsyncPgConnection { } } -impl<'conn, 'query> AsyncConnectionGatWorkaround<'conn, 'query, diesel::pg::Pg> - for AsyncPgConnection -{ - type LoadFuture = BoxFuture<'query, QueryResult>; - type ExecuteFuture = BoxFuture<'query, QueryResult>; - type Stream = BoxStream<'static, QueryResult>; - - type Row = PgRow; -} - #[async_trait::async_trait] impl AsyncConnection for AsyncPgConnection { + type LoadFuture<'conn, 'query> = BoxFuture<'query, QueryResult>>; + type ExecuteFuture<'conn, 'query> = BoxFuture<'query, QueryResult>; + type Stream<'conn, 'query> = BoxStream<'static, QueryResult>; + type Row<'conn, 'query> = PgRow; type Backend = diesel::pg::Pg; type TransactionManager = AnsiTransactionManager; @@ -137,10 +129,7 @@ impl AsyncConnection for AsyncPgConnection { Self::try_from(client).await } - fn load<'conn, 'query, T>( - &'conn mut self, - source: T, - ) -> >::LoadFuture + fn load<'conn, 'query, T>(&'conn mut self, source: T) -> Self::LoadFuture<'conn, 'query> where T: AsQuery + Send + 'query, T::Query: QueryFragment + QueryId + Send + 'query, @@ -171,7 +160,7 @@ impl AsyncConnection for AsyncPgConnection { fn execute_returning_count<'conn, 'query, T>( &'conn mut self, source: T, - ) -> >::ExecuteFuture + ) -> Self::ExecuteFuture<'conn, 'query> where T: QueryFragment + QueryId + Send + 'query, { @@ -415,7 +404,7 @@ impl AsyncPgConnection { .collect::>(); let res = callback(raw_connection, stmt.clone(), binds).await; let mut tm = tm.lock().await; - update_transaction_manager_status(res, &mut *tm) + update_transaction_manager_status(res, &mut tm) } } diff --git a/src/pooled_connection/deadpool.rs b/src/pooled_connection/deadpool.rs index 112808f..3c0b513 100644 --- a/src/pooled_connection/deadpool.rs +++ b/src/pooled_connection/deadpool.rs @@ -63,7 +63,7 @@ pub type HookErrorCause = deadpool::managed::HookErrorCause; #[async_trait::async_trait] impl Manager for AsyncDieselConnectionManager where - C: PoolableConnection + Send, + C: PoolableConnection + Send + 'static, { type Type = C; diff --git a/src/pooled_connection/mod.rs b/src/pooled_connection/mod.rs index b4c3809..502a7bf 100644 --- a/src/pooled_connection/mod.rs +++ b/src/pooled_connection/mod.rs @@ -7,7 +7,7 @@ //! * [mobc](self::mobc) use crate::TransactionManager; -use crate::{AsyncConnection, AsyncConnectionGatWorkaround, SimpleAsyncConnection}; +use crate::{AsyncConnection, SimpleAsyncConnection}; use std::fmt; use std::marker::PhantomData; use std::ops::DerefMut; @@ -65,19 +65,6 @@ impl AsyncDieselConnectionManager { } } -impl<'conn, 'query, C, DB> AsyncConnectionGatWorkaround<'conn, 'query, DB> for C -where - DB: diesel::backend::Backend, - C: DerefMut, - C::Target: AsyncConnectionGatWorkaround<'conn, 'query, DB>, -{ - type ExecuteFuture = - >::ExecuteFuture; - type LoadFuture = >::LoadFuture; - type Stream = >::Stream; - type Row = >::Row; -} - #[async_trait::async_trait] impl SimpleAsyncConnection for C where @@ -96,6 +83,16 @@ where C: DerefMut + Send, C::Target: AsyncConnection, { + type ExecuteFuture<'conn, 'query> = + ::ExecuteFuture<'conn, 'query> + where C::Target: 'conn, C: 'conn; + type LoadFuture<'conn, 'query> = ::LoadFuture<'conn, 'query> + where C::Target: 'conn, C: 'conn; + type Stream<'conn, 'query> = ::Stream<'conn, 'query> + where C::Target: 'conn, C: 'conn; + type Row<'conn, 'query> = ::Row<'conn, 'query> + where C::Target: 'conn, C: 'conn; + type Backend = ::Backend; type TransactionManager = @@ -107,10 +104,7 @@ where )) } - fn load<'conn, 'query, T>( - &'conn mut self, - source: T, - ) -> >::LoadFuture + fn load<'conn, 'query, T>(&'conn mut self, source: T) -> Self::LoadFuture<'conn, 'query> where T: diesel::query_builder::AsQuery + Send + 'query, T::Query: diesel::query_builder::QueryFragment @@ -125,7 +119,7 @@ where fn execute_returning_count<'conn, 'query, T>( &'conn mut self, source: T, - ) -> >::ExecuteFuture + ) -> Self::ExecuteFuture<'conn, 'query> where T: diesel::query_builder::QueryFragment + diesel::query_builder::QueryId @@ -208,7 +202,10 @@ pub trait PoolableConnection: AsyncConnection { /// Check if a connection is still valid /// /// The default implementation performs a `SELECT 1` query - async fn ping(&mut self) -> diesel::QueryResult<()> { + async fn ping(&mut self) -> diesel::QueryResult<()> + where + for<'a> Self: 'a, + { use crate::RunQueryDsl; CheckConnectionQuery.execute(self).await.map(|_| ()) } diff --git a/src/run_query_dsl/mod.rs b/src/run_query_dsl/mod.rs index eff30b7..10a57de 100644 --- a/src/run_query_dsl/mod.rs +++ b/src/run_query_dsl/mod.rs @@ -1,11 +1,10 @@ -use std::pin::Pin; - use crate::AsyncConnection; use diesel::associations::HasTable; use diesel::query_builder::IntoUpdateTarget; use diesel::result::QueryResult; use diesel::AsChangeset; use futures::{FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt}; +use std::pin::Pin; /// The traits used by `QueryDsl`. /// @@ -15,7 +14,6 @@ use futures::{FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt}; /// these traits. pub mod methods { use super::*; - use crate::AsyncConnectionGatWorkaround; use diesel::backend::Backend; use diesel::deserialize::FromSqlRow; use diesel::expression::QueryMetadata; @@ -39,7 +37,7 @@ pub mod methods { fn execute<'conn, 'query>( query: Self, conn: &'conn mut Conn, - ) -> >::ExecuteFuture + ) -> Conn::ExecuteFuture<'conn, 'query> where Self: 'query; } @@ -53,7 +51,7 @@ pub mod methods { fn execute<'conn, 'query>( query: Self, conn: &'conn mut Conn, - ) -> >::ExecuteFuture + ) -> Conn::ExecuteFuture<'conn, 'query> where Self: 'query, { @@ -61,17 +59,6 @@ pub mod methods { } } - /// This trait is a workaround to emulate GAT on stable rust - /// - /// It is used to specify the return type of [`LoadQuery::internal_load`] - /// which may contain lifetimes - pub trait LoadQueryGatWorkaround<'conn, 'query, Conn, U> { - /// The future returned by [`LoadQuery::internal_load`] - type LoadFuture: Future> + Send; - /// The inner stream returned by [`LoadQuery::internal_load`] - type Stream: Stream> + Send; - } - /// The `load` method /// /// This trait should not be relied on directly by most apps. Its behavior is @@ -79,58 +66,47 @@ pub mod methods { /// to call `load` from generic code. /// /// [`RunQueryDsl`]: super::RunQueryDsl - pub trait LoadQuery<'query, Conn: AsyncConnection, U> - where - for<'a> Self: LoadQueryGatWorkaround<'a, 'query, Conn, U>, - { - /// Load this query - fn internal_load<'conn>( - self, - conn: &'conn mut Conn, - ) -> >::LoadFuture; - } + pub trait LoadQuery<'query, Conn: AsyncConnection, U> { + /// The future returned by [`LoadQuery::internal_load`] + type LoadFuture<'conn>: Future>> + Send + where + Conn: 'conn; + /// The inner stream returned by [`LoadQuery::internal_load`] + type Stream<'conn>: Stream> + Send + where + Conn: 'conn; - impl<'conn, 'query, Conn, U, T, DB, ST> LoadQueryGatWorkaround<'conn, 'query, Conn, U> for T - where - Conn: AsyncConnection, - U: Send, - T: AsQuery + Send, - T::SqlType: CompatibleType, - U: FromSqlRow + Send, - DB: QueryMetadata, - { - type LoadFuture = futures::future::MapOk< - >::LoadFuture, - fn(>::Stream) -> Self::Stream, - >; - type Stream = futures::stream::Map< - >::Stream, - fn( - QueryResult<>::Row>, - ) -> QueryResult, - >; + /// Load this query + fn internal_load(self, conn: &mut Conn) -> Self::LoadFuture<'_>; } impl<'query, Conn, DB, T, U, ST> LoadQuery<'query, Conn, U> for T where Conn: AsyncConnection, U: Send, - DB: Backend, + DB: Backend + 'static, T: AsQuery + Send + 'query, T::Query: QueryFragment + QueryId + Send + 'query, T::SqlType: CompatibleType, - U: FromSqlRow + Send, + U: FromSqlRow + Send + 'static, DB: QueryMetadata, + ST: 'static, { - fn internal_load<'conn>( - self, - conn: &'conn mut Conn, - ) -> >::LoadFuture { - // this cast is required to make rustc happy - // it seems to get otherwise confused about the type of - // this function pointer - let f = map_result_stream_future:: as _; - conn.load(self).map_ok(f) + type LoadFuture<'conn> = futures::future::MapOk< + Conn::LoadFuture<'conn, 'query>, + fn(Conn::Stream<'conn, 'query>) -> Self::Stream<'conn>, + > where Conn: 'conn; + + type Stream<'conn> = futures::stream::Map< + Conn::Stream<'conn, 'query>, + fn( + QueryResult>, + ) -> QueryResult, + >where Conn: 'conn; + + fn internal_load(self, conn: &mut Conn) -> Self::LoadFuture<'_> { + conn.load(self) + .map_ok(map_result_stream_future::) } } @@ -141,8 +117,9 @@ pub mod methods { where S: Stream> + Send + 's, R: diesel::row::Row<'a, DB> + 's, - DB: Backend, - U: FromSqlRow, + DB: Backend + 'static, + U: FromSqlRow + 'static, + ST: 'static, { stream.map(map_row_helper::<_, DB, U, ST>) } @@ -163,9 +140,9 @@ pub mod methods { // but concrete connection implementations might want to have control // about that so that they can support multiple simultan queries on // the same connection +#[allow(type_alias_bounds)] // we need these bounds otherwise we cannot use GAT's pub mod return_futures { - use super::methods; - use crate::{AsyncConnection, AsyncConnectionGatWorkaround}; + use super::methods::LoadQuery; use diesel::QueryResult; use std::pin::Pin; @@ -173,63 +150,30 @@ pub mod return_futures { /// and [`RunQueryDsl::get_results`](super::RunQueryDsl::get_results) /// /// This is essentially `impl Future>>` - pub type LoadFuture<'conn, 'query, Q, Conn, U> = futures::future::AndThen< - >::LoadFuture, - futures::stream::TryCollect< - >::Stream, - Vec, - >, - fn( - >::Stream, - ) -> futures::stream::TryCollect< - >::Stream, - Vec, - >, - >; + pub type LoadFuture<'conn, 'query, Q: LoadQuery<'query, Conn, U>, Conn, U> = + futures::future::AndThen< + Q::LoadFuture<'conn>, + futures::stream::TryCollect, Vec>, + fn(Q::Stream<'conn>) -> futures::stream::TryCollect, Vec>, + >; /// The future returned by [`RunQueryDsl::get_result`](super::RunQueryDsl::get_result) /// /// This is essentially `impl Future>` - pub type GetResult<'conn, 'query, Q, Conn, U> = futures::future::AndThen< - >::LoadFuture, - futures::future::Map< - futures::stream::StreamFuture< - Pin>::Stream>>, + pub type GetResult<'conn, 'query, Q: LoadQuery<'query, Conn, U>, Conn, U> = + futures::future::AndThen< + Q::LoadFuture<'conn>, + futures::future::Map< + futures::stream::StreamFuture>>>, + fn((Option>, Pin>>)) -> QueryResult, >, fn( - ( - Option>, - Pin< - Box<>::Stream>, - >, - ), - ) -> QueryResult, - >, - fn( - >::Stream, - ) -> futures::future::Map< - futures::stream::StreamFuture< - Pin>::Stream>>, + Q::Stream<'conn>, + ) -> futures::future::Map< + futures::stream::StreamFuture>>>, + fn((Option>, Pin>>)) -> QueryResult, >, - fn( - ( - Option>, - Pin< - Box<>::Stream>, - >, - ), - ) -> QueryResult, - >, - >; - - /// The future returned by [`RunQueryDsl::execute`](super::RunQueryDsl::execute) - /// - /// This is essentially `impl Future>` - pub type Execute<'conn, 'query, Conn> = ::Backend, - >>::ExecuteFuture; + >; } /// Methods used to execute queries. @@ -271,10 +215,7 @@ pub trait RunQueryDsl: Sized { /// # Ok(()) /// # } /// ``` - fn execute<'conn, 'query>( - self, - conn: &'conn mut Conn, - ) -> return_futures::Execute<'conn, 'query, Conn> + fn execute<'conn, 'query>(self, conn: &'conn mut Conn) -> Conn::ExecuteFuture<'conn, 'query> where Conn: AsyncConnection + Send, Self: methods::ExecuteDsl + 'query, @@ -394,14 +335,7 @@ pub trait RunQueryDsl: Sized { { stream.try_collect() } - let load_future = self.internal_load(conn); - - // this cast is required to make rustc happy - // it seems to get otherwise confused about the type of - // this function pointer - - let f = collect_result:: as _; - load_future.and_then(f) + self.internal_load(conn).and_then(collect_result::) } /// Executes the given query, returning a [`Stream`] with the returned rows. @@ -523,10 +457,7 @@ pub trait RunQueryDsl: Sized { /// # Ok(()) /// # } /// ``` - fn load_stream<'conn, 'query, U>( - self, - conn: &'conn mut Conn, - ) -> >::LoadFuture + fn load_stream<'conn, 'query, U>(self, conn: &'conn mut Conn) -> Self::LoadFuture<'conn> where Conn: AsyncConnection, U: 'conn, @@ -611,12 +542,10 @@ pub trait RunQueryDsl: Sized { } } - let stream = Box::pin(stream); - let f = map_option_to_result as _; - stream.into_future().map(f) + Box::pin(stream).into_future().map(map_option_to_result) } - let f = get_next_stream_element as _; - self.load_stream(conn).and_then(f) + + self.load_stream(conn).and_then(get_next_stream_element) } /// Runs the command, returning an `Vec` with the affected rows. @@ -746,7 +675,7 @@ pub trait SaveChangesDsl { /// See the trait documentation async fn save_changes(self, connection: &mut Conn) -> QueryResult where - Self: Sized, + Self: Sized + diesel::prelude::Identifiable, Conn: UpdateAndFetchResults, { connection.update_and_fetch(self).await @@ -769,7 +698,10 @@ impl SaveChangesDsl for T where /// * The `Changes` generic parameter represents the changeset that should be stored /// * The `Output` generic parameter represents the type of the response. #[async_trait::async_trait] -pub trait UpdateAndFetchResults: AsyncConnection { +pub trait UpdateAndFetchResults: AsyncConnection +where + Changes: diesel::prelude::Identifiable + HasTable, +{ /// See the traits documentation. async fn update_and_fetch(&mut self, changeset: Changes) -> QueryResult where @@ -813,22 +745,25 @@ where #[cfg(feature = "postgres")] #[async_trait::async_trait] -impl<'b, Changes, Output> UpdateAndFetchResults for crate::AsyncPgConnection +impl<'b, Changes, Output, Tab, V> UpdateAndFetchResults + for crate::AsyncPgConnection where Output: Send, - Changes: Copy + AsChangeset::Table> + IntoUpdateTarget + Send, - diesel::dsl::Update: methods::LoadQuery<'b, crate::AsyncPgConnection, Output>, - Changes::Table: Send + 'b, - Changes::WhereClause: Send + 'b, + Changes: + Copy + AsChangeset + Send + diesel::associations::Identifiable, + Tab: diesel::Table + diesel::query_dsl::methods::FindDsl + 'b, + diesel::dsl::Find: IntoUpdateTarget
, + diesel::query_builder::UpdateStatement: + diesel::query_builder::AsQuery, + diesel::dsl::Update: methods::LoadQuery<'b, Self, Output>, + V: Send + 'b, Changes::Changeset: Send + 'b, - ::AllColumns: diesel::expression::ValidGrouping<()>, - <::AllColumns as diesel::expression::ValidGrouping<()>>::IsAggregate: - diesel::expression::MixedAggregates, - ::FromClause: Send, + Tab::FromClause: Send, { async fn update_and_fetch(&mut self, changeset: Changes) -> QueryResult where Changes: 'async_trait, + Changes::Changeset: 'async_trait, { diesel::update(changeset) .set(changeset) diff --git a/src/stmt_cache.rs b/src/stmt_cache.rs index 2ae1929..69780b7 100644 --- a/src/stmt_cache.rs +++ b/src/stmt_cache.rs @@ -73,7 +73,7 @@ impl StmtCache { let metadata = metadata.to_vec(); let f = async move { let stmt = prepare_fn - .prepare(&*sql, &metadata, PrepareForCache::No) + .prepare(&sql, &metadata, PrepareForCache::No) .await?; Ok((MaybeCached::CannotCache(stmt.0), stmt.1)) } @@ -94,7 +94,7 @@ impl StmtCache { let metadata = metadata.to_vec(); let f = async move { let statement = prepare_fn - .prepare(&*sql, &metadata, PrepareForCache::Yes) + .prepare(&sql, &metadata, PrepareForCache::Yes) .await?; Ok((MaybeCached::Cached(entry.insert(statement.0)), statement.1)) diff --git a/src/transaction_manager.rs b/src/transaction_manager.rs index d588f95..443643e 100644 --- a/src/transaction_manager.rs +++ b/src/transaction_manager.rs @@ -295,7 +295,7 @@ where Cow::from(format!("SAVEPOINT diesel_savepoint_{}", transaction_depth)) } }; - conn.batch_execute(&*start_transaction_sql).await?; + conn.batch_execute(&start_transaction_sql).await?; Self::get_transaction_state(conn)? .change_transaction_depth(TransactionDepthChange::IncreaseDepth)?; @@ -335,7 +335,7 @@ where None => return Err(Error::NotInTransaction), }; - match conn.batch_execute(&*rollback_sql).await { + match conn.batch_execute(&rollback_sql).await { Ok(()) => { Self::get_transaction_state(conn)? .change_transaction_depth(TransactionDepthChange::DecreaseDepth)?; @@ -383,7 +383,7 @@ where transaction_depth.get() - 1 )), }; - match conn.batch_execute(&*commit_sql).await { + match conn.batch_execute(&commit_sql).await { Ok(()) => { Self::get_transaction_state(conn)? .change_transaction_depth(TransactionDepthChange::DecreaseDepth)?;