pub enum StatementCacheKey<DB: Backend> {
    Type(TypeId),
    Sql {
        sql: String,
        bind_types: Vec<DB::TypeMetadata>,
    },
}
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

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.

Fields

§sql: String

contains the sql query string

§bind_types: Vec<DB::TypeMetadata>

contains the types of any bind parameter passed to the query

Implementations§

source§

impl<DB> StatementCacheKey<DB>

source

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

source

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,

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<DB: PartialEq + Backend> PartialEq for StatementCacheKey<DB>

source§

fn eq(&self, other: &StatementCacheKey<DB>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<DB: Eq + Backend> Eq for StatementCacheKey<DB>
where DB::TypeMetadata: Eq,

source§

impl<DB: Backend> StructuralPartialEq for StatementCacheKey<DB>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoSql for T

source§

fn into_sql<T>(self) -> AsExprOf<Self, T>

Convert self to an expression for Diesel’s query builder. Read more
source§

fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>

Convert &self to an expression for Diesel’s query builder. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.