1use std::marker::PhantomData;
2
3use super::*;
4use crate::query_builder::*;
5use crate::result::QueryResult;
6use crate::serialize::ToSql;
7use crate::sql_types::DieselNumericOps;
8
9#[doc(hidden)] #[derive(#[automatically_derived]
impl<T: ::core::fmt::Debug, U: ::core::fmt::Debug> ::core::fmt::Debug for
Bound<T, U> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Bound", "item",
&self.item, "_marker", &&self._marker)
}
}Debug, #[automatically_derived]
impl<T: ::core::clone::Clone, U: ::core::clone::Clone> ::core::clone::Clone
for Bound<T, U> {
#[inline]
fn clone(&self) -> Bound<T, U> {
Bound {
item: ::core::clone::Clone::clone(&self.item),
_marker: ::core::clone::Clone::clone(&self._marker),
}
}
}Clone, #[automatically_derived]
impl<T: ::core::marker::Copy, U: ::core::marker::Copy> ::core::marker::Copy
for Bound<T, U> {
}Copy, const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<T, U, __Rhs> ::std::ops::Add<__Rhs> for Bound<T, U> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Add,
<<Self as Expression>::SqlType as Add>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as Add>::Rhs> {
type Output = ops::Add<Self, __Rhs::Expression>;
fn add(self, rhs: __Rhs) -> Self::Output {
ops::Add::new(self, rhs.as_expression())
}
}
impl<T, U, __Rhs> ::std::ops::Sub<__Rhs> for Bound<T, U> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Sub,
<<Self as Expression>::SqlType as Sub>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as Sub>::Rhs> {
type Output = ops::Sub<Self, __Rhs::Expression>;
fn sub(self, rhs: __Rhs) -> Self::Output {
ops::Sub::new(self, rhs.as_expression())
}
}
impl<T, U, __Rhs> ::std::ops::Mul<__Rhs> for Bound<T, U> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Mul,
<<Self as Expression>::SqlType as Mul>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as Mul>::Rhs> {
type Output = ops::Mul<Self, __Rhs::Expression>;
fn mul(self, rhs: __Rhs) -> Self::Output {
ops::Mul::new(self, rhs.as_expression())
}
}
impl<T, U, __Rhs> ::std::ops::Div<__Rhs> for Bound<T, U> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Div,
<<Self as Expression>::SqlType as Div>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as Div>::Rhs> {
type Output = ops::Div<Self, __Rhs::Expression>;
fn div(self, rhs: __Rhs) -> Self::Output {
ops::Div::new(self, rhs.as_expression())
}
}
};DieselNumericOps)]
11pub struct Bound<T, U> {
12 pub(crate) item: U,
13 _marker: PhantomData<T>,
14}
15
16impl<T, U> Bound<T, U> {
17 #[doc(hidden)] pub fn new(item: U) -> Self {
19 Bound {
20 item,
21 _marker: PhantomData,
22 }
23 }
24}
25
26impl<T, U> Expression for Bound<T, U>
27where
28 T: SqlType + TypedExpressionType,
29{
30 type SqlType = T;
31}
32
33impl<T, U, DB> QueryFragment<DB> for Bound<T, U>
34where
35 DB: Backend + HasSqlType<T>,
36 U: ToSql<T, DB>,
37{
38 fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> {
39 pass.push_bind_param(&self.item)?;
40 Ok(())
41 }
42}
43
44impl<T: QueryId, U> QueryId for Bound<T, U> {
45 type QueryId = Bound<T::QueryId, ()>;
46
47 const HAS_STATIC_QUERY_ID: bool = T::HAS_STATIC_QUERY_ID;
48}
49
50impl<T, U, QS> SelectableExpression<QS> for Bound<T, U> where Bound<T, U>: AppearsOnTable<QS> {}
51
52impl<T, U, QS> AppearsOnTable<QS> for Bound<T, U> where Bound<T, U>: Expression {}
53
54impl<T, U, GB> ValidGrouping<GB> for Bound<T, U> {
55 type IsAggregate = is_aggregate::Never;
56}