Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handling potentially empty value, fix some typos #4304

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading