Trait diesel::query_builder::QueryId
[−]
[src]
pub trait QueryId { type QueryId: Any; const HAS_STATIC_QUERY_ID: bool; fn query_id() -> Option<TypeId> { ... } }
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).
This trait is generally implemented by invoking the impl_query_id!
macro.
See the documentation of the QueryId
type and HAS_STATIC_QUERY_ID
for more details.
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
HAS_STATIC_QUERY_ID: bool = true
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<T: QueryId + ?Sized> QueryId for Box<T>
[src]
impl<'a, T: QueryId + ?Sized> QueryId for &'a T
[src]
impl<A: QueryId> QueryId for (A,)
[src]
impl<A: QueryId, B: QueryId> QueryId for (A, B)
[src]
impl<A: QueryId, B: QueryId, C: QueryId> QueryId for (A, B, C)
[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, E: QueryId> QueryId for (A, B, C, D, E)
[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, 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, 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, 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, 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, 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, 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, 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, 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, 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, P: QueryId> QueryId for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)
[src]
Implementors
impl QueryId for now type QueryId = Self;
impl<ST> QueryId for SqlLiteral<ST> type QueryId = ();
impl<'a, QS, ST, DB> QueryId for BoxableExpression<QS, DB, SqlType = ST> + 'a type QueryId = ();
impl<DB> QueryId for QueryFragment<DB> type QueryId = ();
impl<T, U, Ret> QueryId for DeleteStatement<T, U, Ret> where
T: QueryId,
U: QueryId,
Ret: QueryId, type QueryId = DeleteStatement<T::QueryId, U::QueryId, Ret::QueryId>;impl QueryId for SqlQuery type QueryId = ();
impl<T, U, Op, Ret> QueryId for InsertStatement<T, U, Op, Ret> type QueryId = ();
impl<T, U, V, Ret> QueryId for UpdateStatement<T, U, V, Ret> type QueryId = ();
impl<T> QueryId for Nullable<T> where
T: QueryId + NotNull, type QueryId = T::QueryId;impl QueryId for Bool type QueryId = Self;
impl QueryId for SmallInt type QueryId = Self;
impl QueryId for Integer type QueryId = Self;
impl QueryId for BigInt type QueryId = Self;
impl QueryId for Float type QueryId = Self;
impl QueryId for Double type QueryId = Self;
impl QueryId for Text type QueryId = Self;
impl QueryId for Binary type QueryId = Self;
impl QueryId for Date type QueryId = Self;
impl QueryId for Time type QueryId = Self;
impl QueryId for Timestamp type QueryId = Self;
impl QueryId for Tinyint type QueryId = Self;
impl QueryId for Datetime type QueryId = Self;
impl<T> QueryId for DistinctOnClause<T> where
T: QueryId, type QueryId = DistinctOnClause<T::QueryId>;impl<T> QueryId for Array<T> where
T: QueryId, type QueryId = Array<T::QueryId>;impl<T> QueryId for Range<T> where
T: QueryId, type QueryId = Range<T::QueryId>;impl QueryId for Timestamptz type QueryId = Self;
impl QueryId for Interval type QueryId = Self;
impl QueryId for MacAddr type QueryId = Self;
impl QueryId for Inet type QueryId = Self;
impl QueryId for Cidr type QueryId = Self;
impl QueryId for Oid type QueryId = Self;
impl QueryId for Numeric type QueryId = Self;
impl QueryId for Uuid type QueryId = Self;
impl QueryId for Json type QueryId = Self;
impl QueryId for Jsonb type QueryId = Self;
impl QueryId for Money type QueryId = Self;