[−][src]Trait diesel::query_builder::QueryId
Uniquely identifies queries by their type for the purpose of prepared statement caching.
All types which implement QueryFragment
should also implement this trait
(It is not an actual supertrait of QueryFragment
for boxing purposes).
See the documentation of the QueryId
type and HAS_STATIC_QUERY_ID
for more details.
Deriving
This trait can be automatically derived by Diesel. For example, given this struct:
#[derive(QueryId)] pub struct And<Left, Right> { left: Left, right: Right, }
the following implementation will be generated
impl<Left, Right> QueryId for And<Left, Right> where Left: QueryId, Right: QueryId, { type QueryId = And<Left::QueryId, Right::QueryId>; const HAS_STATIC_QUERY_ID: bool = Left::HAS_STATIC_QUERY_ID && Right::HAS_STATIC_QUERY_ID; }
If the SQL generated by a struct is not uniquely identifiable by its type,
meaning that HAS_STATIC_QUERY_ID
should always be false,
you should not derive this trait.
In that case you should manually implement it instead.
Associated Types
type QueryId: Any
A type which uniquely represents Self
in a SQL query.
Typically this will be a re-construction of Self
using the QueryId
type of each of your type parameters. For example, the type And<Left, Right>
would have type QueryId = And<Left::QueryId, Right::QueryId>
.
The exception to this is when one of your type parameters does not
affect whether the same prepared statement can be used or not. For
example, a bind parameter is represented as Bound<SqlType, RustType>
.
The actual Rust type we are serializing does not matter for the purposes
of prepared statement reuse, but a query which has identical SQL but
different types for its bind parameters requires a new prepared
statement. For this reason, Bound
would have type QueryId = Bound<SqlType::QueryId, ()>
.
If HAS_STATIC_QUERY_ID
is false
, you can put any type here
(typically ()
).
Associated Constants
const HAS_STATIC_QUERY_ID: bool
Can the SQL generated by Self
be uniquely identified by its type?
Typically this question can be answered by looking at whether
unsafe_to_cache_prepared
is called in your implementation of
QueryFragment::walk_ast
. In Diesel itself, the only type which has
false
here, but is potentially safe to store in the prepared statement
cache is a boxed query.
Provided methods
fn query_id() -> Option<TypeId>
Returns the type id of Self::QueryId
if Self::HAS_STATIC_QUERY_ID
.
Returns None
otherwise.
You should never need to override this method.
Implementations on Foreign Types
impl QueryId for ()
[src]
impl QueryId for ()
impl<T: QueryId + ?Sized> QueryId for Box<T>
[src]
impl<T: QueryId + ?Sized> QueryId for Box<T>
impl<'a, T: QueryId + ?Sized> QueryId for &'a T
[src]
impl<'a, T: QueryId + ?Sized> QueryId for &'a T
impl<A: QueryId> QueryId for (A,)
[src]
impl<A: QueryId> QueryId for (A,)
type QueryId = (A::QueryId,)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId> QueryId for (A, B)
[src]
impl<A: QueryId, B: QueryId> QueryId for (A, B)
type QueryId = (A::QueryId, B::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId> QueryId for (A, B, C)
[src]
impl<A: QueryId, B: QueryId, C: QueryId> QueryId for (A, B, C)
type QueryId = (A::QueryId, B::QueryId, C::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId> QueryId for (A, B, C, D)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId> QueryId for (A, B, C, D)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId> QueryId for (A, B, C, D, E)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId> QueryId for (A, B, C, D, E)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId> QueryId for (A, B, C, D, E, F)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId> QueryId for (A, B, C, D, E, F)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId> QueryId for (A, B, C, D, E, F, G)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId> QueryId for (A, B, C, D, E, F, G)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId> QueryId for (A, B, C, D, E, F, G, H)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId> QueryId for (A, B, C, D, E, F, G, H)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId, H::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId> QueryId for (A, B, C, D, E, F, G, H, I)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId> QueryId for (A, B, C, D, E, F, G, H, I)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId, H::QueryId, I::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId, H::QueryId, I::QueryId, J::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId, H::QueryId, I::QueryId, J::QueryId, K::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId, H::QueryId, I::QueryId, J::QueryId, K::QueryId, L::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId, M: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L, M)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId, M: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L, M)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId, H::QueryId, I::QueryId, J::QueryId, K::QueryId, L::QueryId, M::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId, M: QueryId, N: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L, M, N)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId, M: QueryId, N: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L, M, N)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId, H::QueryId, I::QueryId, J::QueryId, K::QueryId, L::QueryId, M::QueryId, N::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId, M: QueryId, N: QueryId, O: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId, M: QueryId, N: QueryId, O: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId, H::QueryId, I::QueryId, J::QueryId, K::QueryId, L::QueryId, M::QueryId, N::QueryId, O::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId, M: QueryId, N: QueryId, O: QueryId, P: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)
[src]
impl<A: QueryId, B: QueryId, C: QueryId, D: QueryId, E: QueryId, F: QueryId, G: QueryId, H: QueryId, I: QueryId, J: QueryId, K: QueryId, L: QueryId, M: QueryId, N: QueryId, O: QueryId, P: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)
type QueryId = (A::QueryId, B::QueryId, C::QueryId, D::QueryId, E::QueryId, F::QueryId, G::QueryId, H::QueryId, I::QueryId, J::QueryId, K::QueryId, L::QueryId, M::QueryId, N::QueryId, O::QueryId, P::QueryId)
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
Implementors
impl QueryId for now
[src]
impl QueryId for now
impl QueryId for Datetime
[src]
impl QueryId for Datetime
impl QueryId for Cidr
[src]
impl QueryId for Cidr
impl QueryId for Inet
[src]
impl QueryId for Inet
impl QueryId for Json
[src]
impl QueryId for Json
impl QueryId for Jsonb
[src]
impl QueryId for Jsonb
impl QueryId for MacAddr
[src]
impl QueryId for MacAddr
impl QueryId for Money
[src]
impl QueryId for Money
impl QueryId for Oid
[src]
impl QueryId for Oid
impl QueryId for Timestamptz
[src]
impl QueryId for Timestamptz
impl QueryId for Uuid
[src]
impl QueryId for Uuid
impl QueryId for SqlQuery
[src]
impl QueryId for SqlQuery
impl QueryId for BigInt
[src]
impl QueryId for BigInt
impl QueryId for Binary
[src]
impl QueryId for Binary
impl QueryId for Bool
[src]
impl QueryId for Bool
impl QueryId for Date
[src]
impl QueryId for Date
impl QueryId for Double
[src]
impl QueryId for Double
impl QueryId for Float
[src]
impl QueryId for Float
impl QueryId for Integer
[src]
impl QueryId for Integer
impl QueryId for Interval
[src]
impl QueryId for Interval
impl QueryId for Numeric
[src]
impl QueryId for Numeric
impl QueryId for SmallInt
[src]
impl QueryId for SmallInt
impl QueryId for Text
[src]
impl QueryId for Text
impl QueryId for Time
[src]
impl QueryId for Time
impl QueryId for Timestamp
[src]
impl QueryId for Timestamp
impl QueryId for TinyInt
[src]
impl QueryId for TinyInt
impl<'a, QS, ST, DB> QueryId for dyn BoxableExpression<QS, DB, SqlType = ST> + 'a
[src]
impl<'a, QS, ST, DB> QueryId for dyn BoxableExpression<QS, DB, SqlType = ST> + 'a
impl<DB> QueryId for dyn QueryFragment<DB>
[src]
impl<DB> QueryId for dyn QueryFragment<DB>
impl<Query: QueryId, Value: QueryId> QueryId for UncheckedBind<Query, Value>
[src]
impl<Query: QueryId, Value: QueryId> QueryId for UncheckedBind<Query, Value>
type QueryId = UncheckedBind<<Query as QueryId>::QueryId, <Value as QueryId>::QueryId>
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<ST, T> QueryId for SqlLiteral<ST, T>
[src]
impl<ST, T> QueryId for SqlLiteral<ST, T>
impl<ST: QueryId> QueryId for Unsigned<ST>
[src]
impl<ST: QueryId> QueryId for Unsigned<ST>
type QueryId = Unsigned<<ST as QueryId>::QueryId>
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<ST: QueryId> QueryId for Array<ST>
[src]
impl<ST: QueryId> QueryId for Array<ST>
type QueryId = Array<<ST as QueryId>::QueryId>
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<ST: QueryId> QueryId for Range<ST>
[src]
impl<ST: QueryId> QueryId for Range<ST>
type QueryId = Range<<ST as QueryId>::QueryId>
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<ST: QueryId> QueryId for Record<ST>
[src]
impl<ST: QueryId> QueryId for Record<ST>
type QueryId = Record<<ST as QueryId>::QueryId>
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<T> QueryId for Nullable<T> where
T: QueryId + NotNull,
[src]
impl<T> QueryId for Nullable<T> where
T: QueryId + NotNull,
impl<T, U, Op, Ret> QueryId for InsertStatement<T, U, Op, Ret>
[src]
impl<T, U, Op, Ret> QueryId for InsertStatement<T, U, Op, Ret>
impl<T, U, V, Ret> QueryId for UpdateStatement<T, U, V, Ret>
[src]
impl<T, U, V, Ret> QueryId for UpdateStatement<T, U, V, Ret>
impl<T: QueryId> QueryId for DistinctOnClause<T>
[src]
impl<T: QueryId> QueryId for DistinctOnClause<T>
type QueryId = DistinctOnClause<<T as QueryId>::QueryId>
const HAS_STATIC_QUERY_ID: bool
[src]
fn query_id() -> Option<TypeId> | [src] |
impl<T: QueryId, U: QueryId, Ret: QueryId> QueryId for DeleteStatement<T, U, Ret>
[src]
impl<T: QueryId, U: QueryId, Ret: QueryId> QueryId for DeleteStatement<T, U, Ret>