use std::marker::PhantomData; use super::*; use crate::query_builder::*; use crate::result::QueryResult; use crate::serialize::ToSql; use crate::sql_types::DieselNumericOps; #[doc(hidden)] // This is used by the `AsExpression` derive #[derive(Debug, Clone, Copy, DieselNumericOps)] pub struct Bound { pub(crate) item: U, _marker: PhantomData, } impl Bound { #[doc(hidden)] // This is used by the `AsExpression` derive pub fn new(item: U) -> Self { Bound { item, _marker: PhantomData, } } } impl Expression for Bound where T: SqlType + TypedExpressionType, { type SqlType = T; } impl QueryFragment for Bound where DB: Backend + HasSqlType, U: ToSql, { fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> { pass.push_bind_param(&self.item)?; Ok(()) } } impl QueryId for Bound { type QueryId = Bound; const HAS_STATIC_QUERY_ID: bool = T::HAS_STATIC_QUERY_ID; } impl SelectableExpression for Bound where Bound: AppearsOnTable {} impl AppearsOnTable for Bound where Bound: Expression {} impl ValidGrouping for Bound { type IsAggregate = is_aggregate::Never; }