diesel/query_builder/nodes/
mod.rs

1use crate::backend::DieselReserveSpecialization;
2use crate::query_builder::*;
3use std::marker::PhantomData;
4
5#[doc(hidden)] // used by the table macro
6pub trait StaticQueryFragment {
7    type Component: 'static;
8    const STATIC_COMPONENT: &'static Self::Component;
9}
10
11#[derive(#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for
    StaticQueryFragmentInstance<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f,
            "StaticQueryFragmentInstance", &&self.0)
    }
}Debug, #[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for
    StaticQueryFragmentInstance<T> {
}Copy, #[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for
    StaticQueryFragmentInstance<T> {
    #[inline]
    fn clone(&self) -> StaticQueryFragmentInstance<T> {
        StaticQueryFragmentInstance(::core::clone::Clone::clone(&self.0))
    }
}Clone)]
12#[doc(hidden)] // used by the table macro
13pub struct StaticQueryFragmentInstance<T>(PhantomData<T>);
14
15impl<T> StaticQueryFragmentInstance<T> {
16    #[doc(hidden)] // used by the table macro
17    pub const fn new() -> Self {
18        Self(PhantomData)
19    }
20}
21
22impl<T, DB> QueryFragment<DB> for StaticQueryFragmentInstance<T>
23where
24    DB: Backend + DieselReserveSpecialization,
25    T: StaticQueryFragment,
26    T::Component: QueryFragment<DB>,
27{
28    fn walk_ast<'b>(&'b self, pass: AstPass<'_, 'b, DB>) -> QueryResult<()> {
29        T::STATIC_COMPONENT.walk_ast(pass)
30    }
31}
32
33#[derive(#[automatically_derived]
impl<'a> ::core::fmt::Debug for Identifier<'a> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Identifier",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl<'a> ::core::marker::Copy for Identifier<'a> { }Copy, #[automatically_derived]
impl<'a> ::core::clone::Clone for Identifier<'a> {
    #[inline]
    fn clone(&self) -> Identifier<'a> {
        let _: ::core::clone::AssertParamIsClone<&'a str>;
        *self
    }
}Clone)]
34#[doc(hidden)] // used by the table macro
35pub struct Identifier<'a>(pub &'a str);
36
37impl<DB: Backend> QueryFragment<DB> for Identifier<'_> {
38    fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>) -> QueryResult<()> {
39        out.push_identifier(self.0)
40    }
41}
42
43pub trait MiddleFragment<DB: Backend> {
44    fn push_sql(&self, pass: AstPass<'_, '_, DB>);
45}
46
47impl<DB: Backend> MiddleFragment<DB> for &str {
48    fn push_sql(&self, mut pass: AstPass<'_, '_, DB>) {
49        pass.push_sql(self);
50    }
51}
52
53#[derive(#[automatically_derived]
impl<T: ::core::fmt::Debug, U: ::core::fmt::Debug, M: ::core::fmt::Debug>
    ::core::fmt::Debug for InfixNode<T, U, M> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "InfixNode",
            "lhs", &self.lhs, "rhs", &self.rhs, "middle", &&self.middle)
    }
}Debug, #[automatically_derived]
impl<T: ::core::marker::Copy, U: ::core::marker::Copy,
    M: ::core::marker::Copy> ::core::marker::Copy for InfixNode<T, U, M> {
}Copy, #[automatically_derived]
impl<T: ::core::clone::Clone, U: ::core::clone::Clone,
    M: ::core::clone::Clone> ::core::clone::Clone for InfixNode<T, U, M> {
    #[inline]
    fn clone(&self) -> InfixNode<T, U, M> {
        InfixNode {
            lhs: ::core::clone::Clone::clone(&self.lhs),
            rhs: ::core::clone::Clone::clone(&self.rhs),
            middle: ::core::clone::Clone::clone(&self.middle),
        }
    }
}Clone)]
54#[doc(hidden)] // used by the table macro
55pub struct InfixNode<T, U, M> {
56    lhs: T,
57    rhs: U,
58    middle: M,
59}
60
61impl<T, U, M> InfixNode<T, U, M> {
62    #[doc(hidden)] // used by the table macro
63    pub const fn new(lhs: T, rhs: U, middle: M) -> Self {
64        InfixNode { lhs, rhs, middle }
65    }
66}
67
68impl<T, U, DB, M> QueryFragment<DB> for InfixNode<T, U, M>
69where
70    DB: Backend + DieselReserveSpecialization,
71    T: QueryFragment<DB>,
72    U: QueryFragment<DB>,
73    M: MiddleFragment<DB>,
74{
75    fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>) -> QueryResult<()> {
76        self.lhs.walk_ast(out.reborrow())?;
77        self.middle.push_sql(out.reborrow());
78        self.rhs.walk_ast(out.reborrow())?;
79        Ok(())
80    }
81}