1use crate::backend::Backend;
2use crate::expression::{Expression, TypedExpressionType, ValidGrouping};
3use crate::query_builder::*;
4use crate::result::QueryResult;
5use crate::sql_types;
6
7macro_rules! numeric_operation {
8 ($name:ident, $op:expr) => {
9 #[doc(hidden)]
10 #[derive(Debug, Copy, Clone, QueryId, ValidGrouping)]
11 pub struct $name<Lhs, Rhs> {
12 lhs: Lhs,
13 rhs: Rhs,
14 }
15
16 impl<Lhs, Rhs> $name<Lhs, Rhs> {
17 #[doc(hidden)]
21 pub fn new(left: Lhs, right: Rhs) -> Self {
22 $name {
23 lhs: left,
24 rhs: right,
25 }
26 }
27 }
28
29 impl<Lhs, Rhs> Expression for $name<Lhs, Rhs>
30 where
31 Lhs: Expression,
32 Lhs::SqlType: sql_types::ops::$name,
33 Rhs: Expression,
34 <Lhs::SqlType as sql_types::ops::$name>::Output: TypedExpressionType,
35 {
36 type SqlType = <Lhs::SqlType as sql_types::ops::$name>::Output;
37 }
38
39 impl<Lhs, Rhs, DB> QueryFragment<DB> for $name<Lhs, Rhs>
40 where
41 DB: Backend,
42 Lhs: QueryFragment<DB>,
43 Rhs: QueryFragment<DB>,
44 {
45 fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>) -> QueryResult<()>
46 {
47 out.push_sql("(");
48 self.lhs.walk_ast(out.reborrow())?;
49 out.push_sql($op);
50 self.rhs.walk_ast(out.reborrow())?;
51 out.push_sql(")");
52 Ok(())
53 }
54 }
55
56 impl_selectable_expression!($name<Lhs, Rhs>);
57 generic_numeric_expr!($name, A, B);
58 };
59}
60
61#[doc(hidden)]
pub struct Add<Lhs, Rhs> {
lhs: Lhs,
rhs: Rhs,
}
#[automatically_derived]
impl<Lhs: ::core::fmt::Debug, Rhs: ::core::fmt::Debug> ::core::fmt::Debug for
Add<Lhs, Rhs> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Add", "lhs",
&self.lhs, "rhs", &&self.rhs)
}
}
#[automatically_derived]
impl<Lhs: ::core::marker::Copy, Rhs: ::core::marker::Copy>
::core::marker::Copy for Add<Lhs, Rhs> {
}
#[automatically_derived]
impl<Lhs: ::core::clone::Clone, Rhs: ::core::clone::Clone>
::core::clone::Clone for Add<Lhs, Rhs> {
#[inline]
fn clone(&self) -> Add<Lhs, Rhs> {
Add {
lhs: ::core::clone::Clone::clone(&self.lhs),
rhs: ::core::clone::Clone::clone(&self.rhs),
}
}
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<Lhs: diesel::query_builder::QueryId,
Rhs: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for Add<Lhs, Rhs> {
type QueryId =
Add<<Lhs as diesel::query_builder::QueryId>::QueryId,
<Rhs as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<Lhs as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<Rhs as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<Lhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<Rhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
|| false;
}
};
const _: () =
{
use diesel;
impl<Lhs, Rhs, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
Add<Lhs, Rhs> where
Lhs: diesel::expression::ValidGrouping<__GroupByClause>,
Rhs: diesel::expression::ValidGrouping<__GroupByClause>,
<Lhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<Rhs
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<Lhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<Rhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<Lhs, Rhs> Add<Lhs, Rhs> {
#[doc(hidden)]
pub fn new(left: Lhs, right: Rhs) -> Self {
Add { lhs: left, rhs: right }
}
}
impl<Lhs, Rhs> Expression for Add<Lhs, Rhs> where Lhs: Expression,
Lhs::SqlType: sql_types::ops::Add, Rhs: Expression,
<Lhs::SqlType as sql_types::ops::Add>::Output: TypedExpressionType {
type SqlType = <Lhs::SqlType as sql_types::ops::Add>::Output;
}
impl<Lhs, Rhs, DB> QueryFragment<DB> for Add<Lhs, Rhs> where DB: Backend,
Lhs: QueryFragment<DB>, Rhs: QueryFragment<DB> {
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>)
-> QueryResult<()> {
out.push_sql("(");
self.lhs.walk_ast(out.reborrow())?;
out.push_sql(" + ");
self.rhs.walk_ast(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
impl<Lhs, Rhs, QS> crate::expression::SelectableExpression<QS> for
Add<Lhs, Rhs> where Add<Lhs, Rhs>: crate::expression::AppearsOnTable<QS>,
Lhs: crate::expression::SelectableExpression<QS>,
Rhs: crate::expression::SelectableExpression<QS> {}
impl<Lhs, Rhs, QS> crate::expression::AppearsOnTable<QS> for Add<Lhs, Rhs>
where Add<Lhs, Rhs>: crate::expression::Expression,
Lhs: crate::expression::AppearsOnTable<QS>,
Rhs: crate::expression::AppearsOnTable<QS> {}
impl<Rhs, A, B> ::std::ops::Add<Rhs> for Add<A, B> where
Add<A, B>: crate::expression::Expression,
<Add<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Add,
<<Add<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Add>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Add<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Add>::Rhs> {
type Output = crate::expression::ops::Add<Self, Rhs::Expression>;
fn add(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Add::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Sub<Rhs> for Add<A, B> where
Add<A, B>: crate::expression::Expression,
<Add<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Sub,
<<Add<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Sub>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Add<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Sub>::Rhs> {
type Output = crate::expression::ops::Sub<Self, Rhs::Expression>;
fn sub(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Sub::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Div<Rhs> for Add<A, B> where
Add<A, B>: crate::expression::Expression,
<Add<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Div,
<<Add<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Div>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Add<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Div>::Rhs> {
type Output = crate::expression::ops::Div<Self, Rhs::Expression>;
fn div(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Div::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Mul<Rhs> for Add<A, B> where
Add<A, B>: crate::expression::Expression,
<Add<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Mul,
<<Add<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Mul>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Add<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Mul>::Rhs> {
type Output = crate::expression::ops::Mul<Self, Rhs::Expression>;
fn mul(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Mul::new(self, rhs.as_expression())
}
}numeric_operation!(Add, " + ");
62#[doc(hidden)]
pub struct Sub<Lhs, Rhs> {
lhs: Lhs,
rhs: Rhs,
}
#[automatically_derived]
impl<Lhs: ::core::fmt::Debug, Rhs: ::core::fmt::Debug> ::core::fmt::Debug for
Sub<Lhs, Rhs> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Sub", "lhs",
&self.lhs, "rhs", &&self.rhs)
}
}
#[automatically_derived]
impl<Lhs: ::core::marker::Copy, Rhs: ::core::marker::Copy>
::core::marker::Copy for Sub<Lhs, Rhs> {
}
#[automatically_derived]
impl<Lhs: ::core::clone::Clone, Rhs: ::core::clone::Clone>
::core::clone::Clone for Sub<Lhs, Rhs> {
#[inline]
fn clone(&self) -> Sub<Lhs, Rhs> {
Sub {
lhs: ::core::clone::Clone::clone(&self.lhs),
rhs: ::core::clone::Clone::clone(&self.rhs),
}
}
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<Lhs: diesel::query_builder::QueryId,
Rhs: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for Sub<Lhs, Rhs> {
type QueryId =
Sub<<Lhs as diesel::query_builder::QueryId>::QueryId,
<Rhs as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<Lhs as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<Rhs as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<Lhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<Rhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
|| false;
}
};
const _: () =
{
use diesel;
impl<Lhs, Rhs, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
Sub<Lhs, Rhs> where
Lhs: diesel::expression::ValidGrouping<__GroupByClause>,
Rhs: diesel::expression::ValidGrouping<__GroupByClause>,
<Lhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<Rhs
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<Lhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<Rhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<Lhs, Rhs> Sub<Lhs, Rhs> {
#[doc(hidden)]
pub fn new(left: Lhs, right: Rhs) -> Self {
Sub { lhs: left, rhs: right }
}
}
impl<Lhs, Rhs> Expression for Sub<Lhs, Rhs> where Lhs: Expression,
Lhs::SqlType: sql_types::ops::Sub, Rhs: Expression,
<Lhs::SqlType as sql_types::ops::Sub>::Output: TypedExpressionType {
type SqlType = <Lhs::SqlType as sql_types::ops::Sub>::Output;
}
impl<Lhs, Rhs, DB> QueryFragment<DB> for Sub<Lhs, Rhs> where DB: Backend,
Lhs: QueryFragment<DB>, Rhs: QueryFragment<DB> {
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>)
-> QueryResult<()> {
out.push_sql("(");
self.lhs.walk_ast(out.reborrow())?;
out.push_sql(" - ");
self.rhs.walk_ast(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
impl<Lhs, Rhs, QS> crate::expression::SelectableExpression<QS> for
Sub<Lhs, Rhs> where Sub<Lhs, Rhs>: crate::expression::AppearsOnTable<QS>,
Lhs: crate::expression::SelectableExpression<QS>,
Rhs: crate::expression::SelectableExpression<QS> {}
impl<Lhs, Rhs, QS> crate::expression::AppearsOnTable<QS> for Sub<Lhs, Rhs>
where Sub<Lhs, Rhs>: crate::expression::Expression,
Lhs: crate::expression::AppearsOnTable<QS>,
Rhs: crate::expression::AppearsOnTable<QS> {}
impl<Rhs, A, B> ::std::ops::Add<Rhs> for Sub<A, B> where
Sub<A, B>: crate::expression::Expression,
<Sub<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Add,
<<Sub<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Add>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Sub<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Add>::Rhs> {
type Output = crate::expression::ops::Add<Self, Rhs::Expression>;
fn add(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Add::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Sub<Rhs> for Sub<A, B> where
Sub<A, B>: crate::expression::Expression,
<Sub<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Sub,
<<Sub<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Sub>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Sub<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Sub>::Rhs> {
type Output = crate::expression::ops::Sub<Self, Rhs::Expression>;
fn sub(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Sub::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Div<Rhs> for Sub<A, B> where
Sub<A, B>: crate::expression::Expression,
<Sub<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Div,
<<Sub<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Div>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Sub<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Div>::Rhs> {
type Output = crate::expression::ops::Div<Self, Rhs::Expression>;
fn div(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Div::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Mul<Rhs> for Sub<A, B> where
Sub<A, B>: crate::expression::Expression,
<Sub<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Mul,
<<Sub<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Mul>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Sub<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Mul>::Rhs> {
type Output = crate::expression::ops::Mul<Self, Rhs::Expression>;
fn mul(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Mul::new(self, rhs.as_expression())
}
}numeric_operation!(Sub, " - ");
63#[doc(hidden)]
pub struct Mul<Lhs, Rhs> {
lhs: Lhs,
rhs: Rhs,
}
#[automatically_derived]
impl<Lhs: ::core::fmt::Debug, Rhs: ::core::fmt::Debug> ::core::fmt::Debug for
Mul<Lhs, Rhs> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Mul", "lhs",
&self.lhs, "rhs", &&self.rhs)
}
}
#[automatically_derived]
impl<Lhs: ::core::marker::Copy, Rhs: ::core::marker::Copy>
::core::marker::Copy for Mul<Lhs, Rhs> {
}
#[automatically_derived]
impl<Lhs: ::core::clone::Clone, Rhs: ::core::clone::Clone>
::core::clone::Clone for Mul<Lhs, Rhs> {
#[inline]
fn clone(&self) -> Mul<Lhs, Rhs> {
Mul {
lhs: ::core::clone::Clone::clone(&self.lhs),
rhs: ::core::clone::Clone::clone(&self.rhs),
}
}
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<Lhs: diesel::query_builder::QueryId,
Rhs: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for Mul<Lhs, Rhs> {
type QueryId =
Mul<<Lhs as diesel::query_builder::QueryId>::QueryId,
<Rhs as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<Lhs as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<Rhs as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<Lhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<Rhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
|| false;
}
};
const _: () =
{
use diesel;
impl<Lhs, Rhs, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
Mul<Lhs, Rhs> where
Lhs: diesel::expression::ValidGrouping<__GroupByClause>,
Rhs: diesel::expression::ValidGrouping<__GroupByClause>,
<Lhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<Rhs
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<Lhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<Rhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<Lhs, Rhs> Mul<Lhs, Rhs> {
#[doc(hidden)]
pub fn new(left: Lhs, right: Rhs) -> Self {
Mul { lhs: left, rhs: right }
}
}
impl<Lhs, Rhs> Expression for Mul<Lhs, Rhs> where Lhs: Expression,
Lhs::SqlType: sql_types::ops::Mul, Rhs: Expression,
<Lhs::SqlType as sql_types::ops::Mul>::Output: TypedExpressionType {
type SqlType = <Lhs::SqlType as sql_types::ops::Mul>::Output;
}
impl<Lhs, Rhs, DB> QueryFragment<DB> for Mul<Lhs, Rhs> where DB: Backend,
Lhs: QueryFragment<DB>, Rhs: QueryFragment<DB> {
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>)
-> QueryResult<()> {
out.push_sql("(");
self.lhs.walk_ast(out.reborrow())?;
out.push_sql(" * ");
self.rhs.walk_ast(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
impl<Lhs, Rhs, QS> crate::expression::SelectableExpression<QS> for
Mul<Lhs, Rhs> where Mul<Lhs, Rhs>: crate::expression::AppearsOnTable<QS>,
Lhs: crate::expression::SelectableExpression<QS>,
Rhs: crate::expression::SelectableExpression<QS> {}
impl<Lhs, Rhs, QS> crate::expression::AppearsOnTable<QS> for Mul<Lhs, Rhs>
where Mul<Lhs, Rhs>: crate::expression::Expression,
Lhs: crate::expression::AppearsOnTable<QS>,
Rhs: crate::expression::AppearsOnTable<QS> {}
impl<Rhs, A, B> ::std::ops::Add<Rhs> for Mul<A, B> where
Mul<A, B>: crate::expression::Expression,
<Mul<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Add,
<<Mul<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Add>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Mul<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Add>::Rhs> {
type Output = crate::expression::ops::Add<Self, Rhs::Expression>;
fn add(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Add::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Sub<Rhs> for Mul<A, B> where
Mul<A, B>: crate::expression::Expression,
<Mul<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Sub,
<<Mul<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Sub>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Mul<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Sub>::Rhs> {
type Output = crate::expression::ops::Sub<Self, Rhs::Expression>;
fn sub(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Sub::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Div<Rhs> for Mul<A, B> where
Mul<A, B>: crate::expression::Expression,
<Mul<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Div,
<<Mul<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Div>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Mul<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Div>::Rhs> {
type Output = crate::expression::ops::Div<Self, Rhs::Expression>;
fn div(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Div::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Mul<Rhs> for Mul<A, B> where
Mul<A, B>: crate::expression::Expression,
<Mul<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Mul,
<<Mul<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Mul>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Mul<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Mul>::Rhs> {
type Output = crate::expression::ops::Mul<Self, Rhs::Expression>;
fn mul(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Mul::new(self, rhs.as_expression())
}
}numeric_operation!(Mul, " * ");
64#[doc(hidden)]
pub struct Div<Lhs, Rhs> {
lhs: Lhs,
rhs: Rhs,
}
#[automatically_derived]
impl<Lhs: ::core::fmt::Debug, Rhs: ::core::fmt::Debug> ::core::fmt::Debug for
Div<Lhs, Rhs> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Div", "lhs",
&self.lhs, "rhs", &&self.rhs)
}
}
#[automatically_derived]
impl<Lhs: ::core::marker::Copy, Rhs: ::core::marker::Copy>
::core::marker::Copy for Div<Lhs, Rhs> {
}
#[automatically_derived]
impl<Lhs: ::core::clone::Clone, Rhs: ::core::clone::Clone>
::core::clone::Clone for Div<Lhs, Rhs> {
#[inline]
fn clone(&self) -> Div<Lhs, Rhs> {
Div {
lhs: ::core::clone::Clone::clone(&self.lhs),
rhs: ::core::clone::Clone::clone(&self.rhs),
}
}
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<Lhs: diesel::query_builder::QueryId,
Rhs: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for Div<Lhs, Rhs> {
type QueryId =
Div<<Lhs as diesel::query_builder::QueryId>::QueryId,
<Rhs as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<Lhs as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<Rhs as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<Lhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<Rhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
|| false;
}
};
const _: () =
{
use diesel;
impl<Lhs, Rhs, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
Div<Lhs, Rhs> where
Lhs: diesel::expression::ValidGrouping<__GroupByClause>,
Rhs: diesel::expression::ValidGrouping<__GroupByClause>,
<Lhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<Rhs
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<Lhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<Rhs as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<Lhs, Rhs> Div<Lhs, Rhs> {
#[doc(hidden)]
pub fn new(left: Lhs, right: Rhs) -> Self {
Div { lhs: left, rhs: right }
}
}
impl<Lhs, Rhs> Expression for Div<Lhs, Rhs> where Lhs: Expression,
Lhs::SqlType: sql_types::ops::Div, Rhs: Expression,
<Lhs::SqlType as sql_types::ops::Div>::Output: TypedExpressionType {
type SqlType = <Lhs::SqlType as sql_types::ops::Div>::Output;
}
impl<Lhs, Rhs, DB> QueryFragment<DB> for Div<Lhs, Rhs> where DB: Backend,
Lhs: QueryFragment<DB>, Rhs: QueryFragment<DB> {
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>)
-> QueryResult<()> {
out.push_sql("(");
self.lhs.walk_ast(out.reborrow())?;
out.push_sql(" / ");
self.rhs.walk_ast(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
impl<Lhs, Rhs, QS> crate::expression::SelectableExpression<QS> for
Div<Lhs, Rhs> where Div<Lhs, Rhs>: crate::expression::AppearsOnTable<QS>,
Lhs: crate::expression::SelectableExpression<QS>,
Rhs: crate::expression::SelectableExpression<QS> {}
impl<Lhs, Rhs, QS> crate::expression::AppearsOnTable<QS> for Div<Lhs, Rhs>
where Div<Lhs, Rhs>: crate::expression::Expression,
Lhs: crate::expression::AppearsOnTable<QS>,
Rhs: crate::expression::AppearsOnTable<QS> {}
impl<Rhs, A, B> ::std::ops::Add<Rhs> for Div<A, B> where
Div<A, B>: crate::expression::Expression,
<Div<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Add,
<<Div<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Add>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Div<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Add>::Rhs> {
type Output = crate::expression::ops::Add<Self, Rhs::Expression>;
fn add(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Add::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Sub<Rhs> for Div<A, B> where
Div<A, B>: crate::expression::Expression,
<Div<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Sub,
<<Div<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Sub>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Div<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Sub>::Rhs> {
type Output = crate::expression::ops::Sub<Self, Rhs::Expression>;
fn sub(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Sub::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Div<Rhs> for Div<A, B> where
Div<A, B>: crate::expression::Expression,
<Div<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Div,
<<Div<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Div>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Div<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Div>::Rhs> {
type Output = crate::expression::ops::Div<Self, Rhs::Expression>;
fn div(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Div::new(self, rhs.as_expression())
}
}
impl<Rhs, A, B> ::std::ops::Mul<Rhs> for Div<A, B> where
Div<A, B>: crate::expression::Expression,
<Div<A, B> as crate::Expression>::SqlType: crate::sql_types::SqlType +
crate::sql_types::ops::Mul,
<<Div<A, B> as crate::Expression>::SqlType as
crate::sql_types::ops::Mul>::Rhs: crate::expression::TypedExpressionType,
Rhs: crate::expression::AsExpression<<<Div<A, B> as
crate::Expression>::SqlType as crate::sql_types::ops::Mul>::Rhs> {
type Output = crate::expression::ops::Mul<Self, Rhs::Expression>;
fn mul(self, rhs: Rhs) -> Self::Output {
crate::expression::ops::Mul::new(self, rhs.as_expression())
}
}numeric_operation!(Div, " / ");