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

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 as Backend>::QueryBuilder: Default,
    <DB as TypeMetadata>::TypeMetadata: Clone,

source

pub fn for_source<T>(
    source: &T,
    bind_types: &[<DB as TypeMetadata>::TypeMetadata],
    backend: &DB
) -> Result<StatementCacheKey<DB>, Error>where
    T: QueryFragment<DB, NotSpecialized> + QueryId,

Create a new statement cache key for the given query source

source

pub fn sql<T>(&self, source: &T, backend: &DB) -> Result<Cow<'_, str>, Error>where
    T: QueryFragment<DB, NotSpecialized>,

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 for StatementCacheKey<DB>where
    DB: Hash + Backend,
    <DB as TypeMetadata>::TypeMetadata: Hash,

source§

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

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

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 for StatementCacheKey<DB>where
    DB: Eq + Backend,
    <DB as TypeMetadata>::TypeMetadata: Eq,

source§

impl<DB> StructuralEq for StatementCacheKey<DB>where
    DB: Backend,

source§

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

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> 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) -> Self::Expressionwhere
    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) -> <&'a Self as AsExpression<T>>::Expressionwhere
    &'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.