Skip to content

Commit

Permalink
Merge pull request #4304 from sharma-shray/master
Browse files Browse the repository at this point in the history
 handling potentially empty value, fix some typos
  • Loading branch information
weiznich authored Oct 25, 2024
2 parents 41f6553 + 65d1c03 commit a292e1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions diesel/src/connection/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 8 additions & 5 deletions diesel/src/connection/statement_cache/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DB>,
Expand Down Expand Up @@ -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::<RecordCacheEvents>()
.unwrap()
.list
.len()
{
events.list.len()
} else {
0
}
}
}

Expand Down

0 comments on commit a292e1d

Please sign in to comment.