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

§sql: String

contains the sql query string

§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,

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<StatementCacheKey<DB>> for StatementCacheKey<DB>where DB::TypeMetadata: PartialEq,

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> StructuralEq for StatementCacheKey<DB>

source§

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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>where Self: AsExpression<T> + Sized, T: SqlType + TypedExpressionType,

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

fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V