From 79bb641df370a99ac0f874f6055c89dab1984e23 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Sat, 12 Oct 2024 18:40:13 +0200 Subject: [PATCH 1/2] upd --- diesel/src/connection/instrumentation.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/diesel/src/connection/instrumentation.rs b/diesel/src/connection/instrumentation.rs index 7700882a213a..b564c90a9c0b 100644 --- a/diesel/src/connection/instrumentation.rs +++ b/diesel/src/connection/instrumentation.rs @@ -69,16 +69,16 @@ impl DebugQuery for StrQueryHelper<'_> {} /// implementation of the enum itself and any of its fields /// is not guarantee to be stable. // -// This types is carefully designed +// This type is carefully designed // to avoid any potential overhead by // taking references for all things // and by not performing any additional // work until required. // In addition it's carefully designed // not to be dependent on the actual backend -// type, as that makes it easier to to reuse +// type, as that makes it easier to reuse // `Instrumentation` implementations in -// different a different context +// a different context #[derive(Debug)] #[non_exhaustive] pub enum InstrumentationEvent<'a> { @@ -243,7 +243,7 @@ impl<'a> InstrumentationEvent<'a> { /// `tracing` and `log` are supposed to be part of their own /// crates. pub trait Instrumentation: Downcast + Send + 'static { - /// The function that is invoced for each event + /// The function that is invoked for each event fn on_connection_event(&mut self, event: InstrumentationEvent<'_>); } downcast_rs::impl_downcast!(Instrumentation); From 65d1c03cee162303f31a30cfb3bd0a675c162960 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Sat, 12 Oct 2024 18:40:57 +0200 Subject: [PATCH 2/2] upd --- diesel/src/connection/statement_cache/strategy.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/diesel/src/connection/statement_cache/strategy.rs b/diesel/src/connection/statement_cache/strategy.rs index 2636070a46cc..7c7919038827 100644 --- a/diesel/src/connection/statement_cache/strategy.rs +++ b/diesel/src/connection/statement_cache/strategy.rs @@ -20,7 +20,7 @@ where /// The implementation will decide whether to cache statement or not /// * `prepare_fn` - will be invoked if prepared statement wasn't cached already /// * first argument is sql query string - /// * second argument specify whether statement will be cached (true) or not (false). + /// * second argument specifies whether statement will be cached (true) or not (false). fn get( &mut self, key: StatementCacheKey, @@ -131,12 +131,15 @@ mod testing_utils { } pub fn count_cache_calls(conn: &mut impl Connection) -> usize { - conn.instrumentation() + if let Some(events) = conn + .instrumentation() .as_any() .downcast_ref::() - .unwrap() - .list - .len() + { + events.list.len() + } else { + 0 + } } }