pub enum StatementCacheKey<DB: Backend> {
Type(TypeId),
Sql {
sql: String,
bind_types: Vec<DB::TypeMetadata>,
},
}
i-implement-a-third-party-backend-and-opt-into-breaking-changes
only.Expand description
The lookup key used by StatementCache
internally
This can contain either a at compile time known type id (representing a statically known query) or a at runtime calculated query string + parameter types (for queries that may change depending on their parameters)
Variants§
Type(TypeId)
Represents a at compile time known query
Calculated via QueryId::QueryId
Sql
Fields
bind_types: Vec<DB::TypeMetadata>
contains the types of any bind parameter passed to the query
Represents a dynamically constructed query
This variant is used if QueryId::HAS_STATIC_QUERY_ID
is false
and AstPass::unsafe_to_cache_prepared
is not
called for a given query.
Implementations§
source§impl<DB> StatementCacheKey<DB>where
DB: Backend,
DB::QueryBuilder: Default,
DB::TypeMetadata: Clone,
impl<DB> StatementCacheKey<DB>where DB: Backend, DB::QueryBuilder: Default, DB::TypeMetadata: Clone,
sourcepub fn for_source<T>(
source: &T,
bind_types: &[DB::TypeMetadata],
backend: &DB
) -> QueryResult<Self>where
T: QueryFragment<DB> + QueryId,
pub fn for_source<T>( source: &T, bind_types: &[DB::TypeMetadata], backend: &DB ) -> QueryResult<Self>where T: QueryFragment<DB> + QueryId,
Create a new statement cache key for the given query source
sourcepub fn sql<T: QueryFragment<DB>>(
&self,
source: &T,
backend: &DB
) -> QueryResult<Cow<'_, str>>
pub fn sql<T: QueryFragment<DB>>( &self, source: &T, backend: &DB ) -> QueryResult<Cow<'_, str>>
Get the sql for a given query source based
This is an optimization that may skip constructing the query string twice if it’s already part of the current cache key
Trait Implementations§
source§impl<DB: Hash + Backend> Hash for StatementCacheKey<DB>where
DB::TypeMetadata: Hash,
impl<DB: Hash + Backend> Hash for StatementCacheKey<DB>where DB::TypeMetadata: Hash,
source§impl<DB: PartialEq + Backend> PartialEq<StatementCacheKey<DB>> for StatementCacheKey<DB>where
DB::TypeMetadata: PartialEq,
impl<DB: PartialEq + Backend> PartialEq<StatementCacheKey<DB>> for StatementCacheKey<DB>where DB::TypeMetadata: PartialEq,
source§fn eq(&self, other: &StatementCacheKey<DB>) -> bool
fn eq(&self, other: &StatementCacheKey<DB>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<DB: Eq + Backend> Eq for StatementCacheKey<DB>where DB::TypeMetadata: Eq,
impl<DB: Backend> StructuralEq for StatementCacheKey<DB>
impl<DB: Backend> StructuralPartialEq for StatementCacheKey<DB>
Auto Trait Implementations§
impl<DB> RefUnwindSafe for StatementCacheKey<DB>where <DB as TypeMetadata>::TypeMetadata: RefUnwindSafe,
impl<DB> Send for StatementCacheKey<DB>where <DB as TypeMetadata>::TypeMetadata: Send,
impl<DB> Sync for StatementCacheKey<DB>where <DB as TypeMetadata>::TypeMetadata: Sync,
impl<DB> Unpin for StatementCacheKey<DB>where <DB as TypeMetadata>::TypeMetadata: Unpin,
impl<DB> UnwindSafe for StatementCacheKey<DB>where <DB as TypeMetadata>::TypeMetadata: UnwindSafe,
Blanket Implementations§
source§impl<T> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> AsExprOf<Self, T>where
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
fn into_sql<T>(self) -> AsExprOf<Self, T>where Self: AsExpression<T> + Sized, T: SqlType + TypedExpressionType,
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>where
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,
&self
to an expression for Diesel’s query builder. Read more