Skip to main content

diesel/pg/expression/
functions.rs

1//! PostgreSQL specific functions
2
3use super::expression_methods::InetOrCidr;
4use crate::expression::functions::declare_sql_function;
5use crate::pg::expression::expression_methods::ArrayOrNullableArray;
6use crate::pg::expression::expression_methods::CombinedAllNullableValue;
7use crate::pg::expression::expression_methods::JsonOrNullableJson;
8use crate::pg::expression::expression_methods::JsonbOrNullableJsonb;
9use crate::pg::expression::expression_methods::MaybeNullableValue;
10use crate::pg::expression::expression_methods::MultirangeOrNullableMultirange;
11use crate::pg::expression::expression_methods::MultirangeOrRangeMaybeNullable;
12use crate::pg::expression::expression_methods::RangeOrNullableRange;
13use crate::pg::expression::expression_methods::RecordOrNullableRecord;
14use crate::pg::expression::expression_methods::TextArrayOrNullableTextArray;
15use crate::sql_types::helper::CombinedNullableValue;
16use crate::sql_types::*;
17
18#[doc = " Creates an abbreviated display format as text."]
#[allow(non_camel_case_types)]
pub fn abbrev<T: InetOrCidr + SingleValue, addr>(addr: addr)
    -> abbrev<T, addr> where addr: diesel::expression::AsExpression<T> {
    abbrev_utils::abbrev {
        addr: addr.as_expression(),
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`abbrev()`](fn@abbrev)"]
pub type abbrev<T, addr> =
    abbrev_utils::abbrev<T,
    <addr as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod abbrev_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct abbrev<T, addr> {
        pub(in super) addr: addr,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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, addr, __Rhs> ::std::ops::Add<__Rhs> for abbrev<T, addr>
                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, addr, __Rhs> ::std::ops::Sub<__Rhs> for abbrev<T, addr>
                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, addr, __Rhs> ::std::ops::Mul<__Rhs> for abbrev<T, addr>
                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, addr, __Rhs> ::std::ops::Div<__Rhs> for abbrev<T, addr>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, addr: ::core::fmt::Debug> ::core::fmt::Debug
        for abbrev<T, addr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "abbrev",
                "addr", &self.addr, "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, addr: ::core::clone::Clone>
        ::core::clone::Clone for abbrev<T, addr> {
        #[inline]
        fn clone(&self) -> abbrev<T, addr> {
            abbrev {
                addr: ::core::clone::Clone::clone(&self.addr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, addr: ::core::marker::Copy>
        ::core::marker::Copy for abbrev<T, addr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                addr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for abbrev<T, addr> {
                type QueryId =
                    abbrev<<T as diesel::query_builder::QueryId>::QueryId,
                    <addr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <addr as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <addr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`abbrev()`](fn@abbrev)"]
    pub type HelperType<T, addr> =
        abbrev<T, <addr as AsExpression<T>>::Expression>;
    impl<T: InetOrCidr + SingleValue, addr> Expression for abbrev<T, addr>
        where (addr): Expression {
        type SqlType = Text;
    }
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        SelectableExpression<__DieselInternal> for abbrev<T, addr> where
        addr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for abbrev<T, addr> where
        addr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        FunctionFragment<__DieselInternal> for abbrev<T, addr> where
        __DieselInternal: diesel::backend::Backend,
        addr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "abbrev";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.addr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.addr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, addr> QueryFragment<crate::pg::Pg> for
        abbrev<T, addr> where addr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<addr>(addr);
    const _: () =
        {
            use diesel;
            impl<addr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<addr> where
                addr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <addr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        ValidGrouping<__DieselInternal> for abbrev<T, addr> where
        __Derived<addr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<addr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Computes the broadcast address for the address\'s network."]
#[allow(non_camel_case_types)]
pub fn broadcast<T: InetOrCidr + SingleValue, addr>(addr: addr)
    -> broadcast<T, addr> where addr: diesel::expression::AsExpression<T> {
    broadcast_utils::broadcast {
        addr: addr.as_expression(),
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`broadcast()`](fn@broadcast)"]
pub type broadcast<T, addr> =
    broadcast_utils::broadcast<T,
    <addr as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod broadcast_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct broadcast<T, addr> {
        pub(in super) addr: addr,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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, addr, __Rhs> ::std::ops::Add<__Rhs> for broadcast<T, addr>
                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, addr, __Rhs> ::std::ops::Sub<__Rhs> for broadcast<T, addr>
                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, addr, __Rhs> ::std::ops::Mul<__Rhs> for broadcast<T, addr>
                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, addr, __Rhs> ::std::ops::Div<__Rhs> for broadcast<T, addr>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, addr: ::core::fmt::Debug> ::core::fmt::Debug
        for broadcast<T, addr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "broadcast",
                "addr", &self.addr, "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, addr: ::core::clone::Clone>
        ::core::clone::Clone for broadcast<T, addr> {
        #[inline]
        fn clone(&self) -> broadcast<T, addr> {
            broadcast {
                addr: ::core::clone::Clone::clone(&self.addr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, addr: ::core::marker::Copy>
        ::core::marker::Copy for broadcast<T, addr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                addr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for broadcast<T, addr> {
                type QueryId =
                    broadcast<<T as diesel::query_builder::QueryId>::QueryId,
                    <addr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <addr as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <addr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`broadcast()`](fn@broadcast)"]
    pub type HelperType<T, addr> =
        broadcast<T, <addr as AsExpression<T>>::Expression>;
    impl<T: InetOrCidr + SingleValue, addr> Expression for broadcast<T, addr>
        where (addr): Expression {
        type SqlType = Inet;
    }
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        SelectableExpression<__DieselInternal> for broadcast<T, addr> where
        addr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for broadcast<T, addr> where
        addr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        FunctionFragment<__DieselInternal> for broadcast<T, addr> where
        __DieselInternal: diesel::backend::Backend,
        addr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "broadcast";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.addr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.addr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, addr> QueryFragment<crate::pg::Pg> for
        broadcast<T, addr> where addr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<addr>(addr);
    const _: () =
        {
            use diesel;
            impl<addr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<addr> where
                addr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <addr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        ValidGrouping<__DieselInternal> for broadcast<T, addr> where
        __Derived<addr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<addr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the address\'s family: 4 for IPv4, 6 for IPv6."]
#[allow(non_camel_case_types)]
pub fn family<T: InetOrCidr + SingleValue, addr>(addr: addr)
    -> family<T, addr> where addr: diesel::expression::AsExpression<T> {
    family_utils::family {
        addr: addr.as_expression(),
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`family()`](fn@family)"]
pub type family<T, addr> =
    family_utils::family<T,
    <addr as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod family_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct family<T, addr> {
        pub(in super) addr: addr,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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, addr, __Rhs> ::std::ops::Add<__Rhs> for family<T, addr>
                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, addr, __Rhs> ::std::ops::Sub<__Rhs> for family<T, addr>
                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, addr, __Rhs> ::std::ops::Mul<__Rhs> for family<T, addr>
                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, addr, __Rhs> ::std::ops::Div<__Rhs> for family<T, addr>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, addr: ::core::fmt::Debug> ::core::fmt::Debug
        for family<T, addr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "family",
                "addr", &self.addr, "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, addr: ::core::clone::Clone>
        ::core::clone::Clone for family<T, addr> {
        #[inline]
        fn clone(&self) -> family<T, addr> {
            family {
                addr: ::core::clone::Clone::clone(&self.addr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, addr: ::core::marker::Copy>
        ::core::marker::Copy for family<T, addr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                addr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for family<T, addr> {
                type QueryId =
                    family<<T as diesel::query_builder::QueryId>::QueryId,
                    <addr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <addr as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <addr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`family()`](fn@family)"]
    pub type HelperType<T, addr> =
        family<T, <addr as AsExpression<T>>::Expression>;
    impl<T: InetOrCidr + SingleValue, addr> Expression for family<T, addr>
        where (addr): Expression {
        type SqlType = Integer;
    }
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        SelectableExpression<__DieselInternal> for family<T, addr> where
        addr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for family<T, addr> where
        addr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        FunctionFragment<__DieselInternal> for family<T, addr> where
        __DieselInternal: diesel::backend::Backend,
        addr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "family";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.addr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.addr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, addr> QueryFragment<crate::pg::Pg> for
        family<T, addr> where addr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<addr>(addr);
    const _: () =
        {
            use diesel;
            impl<addr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<addr> where
                addr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <addr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        ValidGrouping<__DieselInternal> for family<T, addr> where
        __Derived<addr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<addr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the IP address as text, ignoring the netmask."]
#[allow(non_camel_case_types)]
pub fn host<T: InetOrCidr + SingleValue, addr>(addr: addr) -> host<T, addr>
    where addr: diesel::expression::AsExpression<T> {
    host_utils::host {
        addr: addr.as_expression(),
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`host()`](fn@host)"]
pub type host<T, addr> =
    host_utils::host<T,
    <addr as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod host_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct host<T, addr> {
        pub(in super) addr: addr,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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, addr, __Rhs> ::std::ops::Add<__Rhs> for host<T, addr>
                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, addr, __Rhs> ::std::ops::Sub<__Rhs> for host<T, addr>
                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, addr, __Rhs> ::std::ops::Mul<__Rhs> for host<T, addr>
                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, addr, __Rhs> ::std::ops::Div<__Rhs> for host<T, addr>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, addr: ::core::fmt::Debug> ::core::fmt::Debug
        for host<T, addr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "host",
                "addr", &self.addr, "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, addr: ::core::clone::Clone>
        ::core::clone::Clone for host<T, addr> {
        #[inline]
        fn clone(&self) -> host<T, addr> {
            host {
                addr: ::core::clone::Clone::clone(&self.addr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, addr: ::core::marker::Copy>
        ::core::marker::Copy for host<T, addr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                addr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for host<T, addr> {
                type QueryId =
                    host<<T as diesel::query_builder::QueryId>::QueryId,
                    <addr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <addr as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <addr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`host()`](fn@host)"]
    pub type HelperType<T, addr> =
        host<T, <addr as AsExpression<T>>::Expression>;
    impl<T: InetOrCidr + SingleValue, addr> Expression for host<T, addr> where
        (addr): Expression {
        type SqlType = Text;
    }
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        SelectableExpression<__DieselInternal> for host<T, addr> where
        addr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for host<T, addr> where
        addr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        FunctionFragment<__DieselInternal> for host<T, addr> where
        __DieselInternal: diesel::backend::Backend,
        addr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "host";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.addr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.addr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, addr> QueryFragment<crate::pg::Pg> for
        host<T, addr> where addr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<addr>(addr);
    const _: () =
        {
            use diesel;
            impl<addr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<addr> where
                addr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <addr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        ValidGrouping<__DieselInternal> for host<T, addr> where
        __Derived<addr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<addr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Computes the host mask for the address\'s network."]
#[allow(non_camel_case_types)]
pub fn hostmask<T: InetOrCidr + SingleValue, addr>(addr: addr)
    -> hostmask<T, addr> where addr: diesel::expression::AsExpression<T> {
    hostmask_utils::hostmask {
        addr: addr.as_expression(),
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`hostmask()`](fn@hostmask)"]
pub type hostmask<T, addr> =
    hostmask_utils::hostmask<T,
    <addr as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod hostmask_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct hostmask<T, addr> {
        pub(in super) addr: addr,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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, addr, __Rhs> ::std::ops::Add<__Rhs> for hostmask<T, addr>
                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, addr, __Rhs> ::std::ops::Sub<__Rhs> for hostmask<T, addr>
                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, addr, __Rhs> ::std::ops::Mul<__Rhs> for hostmask<T, addr>
                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, addr, __Rhs> ::std::ops::Div<__Rhs> for hostmask<T, addr>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, addr: ::core::fmt::Debug> ::core::fmt::Debug
        for hostmask<T, addr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "hostmask",
                "addr", &self.addr, "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, addr: ::core::clone::Clone>
        ::core::clone::Clone for hostmask<T, addr> {
        #[inline]
        fn clone(&self) -> hostmask<T, addr> {
            hostmask {
                addr: ::core::clone::Clone::clone(&self.addr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, addr: ::core::marker::Copy>
        ::core::marker::Copy for hostmask<T, addr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                addr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for hostmask<T, addr> {
                type QueryId =
                    hostmask<<T as diesel::query_builder::QueryId>::QueryId,
                    <addr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <addr as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <addr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`hostmask()`](fn@hostmask)"]
    pub type HelperType<T, addr> =
        hostmask<T, <addr as AsExpression<T>>::Expression>;
    impl<T: InetOrCidr + SingleValue, addr> Expression for hostmask<T, addr>
        where (addr): Expression {
        type SqlType = Inet;
    }
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        SelectableExpression<__DieselInternal> for hostmask<T, addr> where
        addr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for hostmask<T, addr> where
        addr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        FunctionFragment<__DieselInternal> for hostmask<T, addr> where
        __DieselInternal: diesel::backend::Backend,
        addr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "hostmask";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.addr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.addr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, addr> QueryFragment<crate::pg::Pg> for
        hostmask<T, addr> where addr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<addr>(addr);
    const _: () =
        {
            use diesel;
            impl<addr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<addr> where
                addr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <addr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        ValidGrouping<__DieselInternal> for hostmask<T, addr> where
        __Derived<addr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<addr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Computes the smallest network that includes both of the given networks."]
#[allow(non_camel_case_types)]
pub fn inet_merge<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a,
    b>(a: a, b: b) -> inet_merge<T, U, a, b> where
    a: diesel::expression::AsExpression<T>,
    b: diesel::expression::AsExpression<U> {
    inet_merge_utils::inet_merge {
        a: a.as_expression(),
        b: b.as_expression(),
        T: ::std::marker::PhantomData,
        U: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`inet_merge()`](fn@inet_merge)"]
pub type inet_merge<T, U, a, b> =
    inet_merge_utils::inet_merge<T, U,
    <a as diesel::expression::AsExpression<T>>::Expression,
    <b as diesel::expression::AsExpression<U>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod inet_merge_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct inet_merge<T, U, a, b> {
        pub(in super) a: a,
        pub(in super) b: b,
        pub(in super) T: ::std::marker::PhantomData<T>,
        pub(in super) U: ::std::marker::PhantomData<U>,
    }
    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, a, b, __Rhs> ::std::ops::Add<__Rhs> for
                inet_merge<T, U, a, b> 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, a, b, __Rhs> ::std::ops::Sub<__Rhs> for
                inet_merge<T, U, a, b> 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, a, b, __Rhs> ::std::ops::Mul<__Rhs> for
                inet_merge<T, U, a, b> 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, a, b, __Rhs> ::std::ops::Div<__Rhs> for
                inet_merge<T, U, a, b> 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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, U: ::core::fmt::Debug, a: ::core::fmt::Debug,
        b: ::core::fmt::Debug> ::core::fmt::Debug for inet_merge<T, U, a, b> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "inet_merge", "a", &self.a, "b", &self.b, "T", &self.T, "U",
                &&self.U)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, U: ::core::clone::Clone,
        a: ::core::clone::Clone, b: ::core::clone::Clone> ::core::clone::Clone
        for inet_merge<T, U, a, b> {
        #[inline]
        fn clone(&self) -> inet_merge<T, U, a, b> {
            inet_merge {
                a: ::core::clone::Clone::clone(&self.a),
                b: ::core::clone::Clone::clone(&self.b),
                T: ::core::clone::Clone::clone(&self.T),
                U: ::core::clone::Clone::clone(&self.U),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, U: ::core::marker::Copy,
        a: ::core::marker::Copy, b: ::core::marker::Copy> ::core::marker::Copy
        for inet_merge<T, U, a, b> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                U: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                b: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for inet_merge<T, U, a, b> {
                type QueryId =
                    inet_merge<<T as diesel::query_builder::QueryId>::QueryId,
                    <U as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <b as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <U as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <b as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                    <U as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <b as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`inet_merge()`](fn@inet_merge)"]
    pub type HelperType<T, U, a, b> =
        inet_merge<T, U, <a as AsExpression<T>>::Expression,
        <b as AsExpression<U>>::Expression>;
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b>
        Expression for inet_merge<T, U, a, b> where (a, b): Expression {
        type SqlType = Cidr;
    }
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        inet_merge<T, U, a, b> where
        a: SelectableExpression<__DieselInternal>,
        b: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        inet_merge<T, U, a, b> where a: AppearsOnTable<__DieselInternal>,
        b: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        inet_merge<T, U, a, b> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>, b: QueryFragment<__DieselInternal>
        {
        const FUNCTION_NAME: &'static str = "inet_merge";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.b.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.b.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b>
        QueryFragment<crate::pg::Pg> for inet_merge<T, U, a, b> where
        a: QueryFragment<crate::pg::Pg>, b: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, b>(a, b);
    const _: () =
        {
            use diesel;
            impl<a, b, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, b> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                b: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<b
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<b as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        inet_merge<T, U, a, b> where
        __Derived<a, b>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, b> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Tests whether the addresses belong to the same IP family."]
#[allow(non_camel_case_types)]
pub fn inet_same_family<T: InetOrCidr + SingleValue, U: InetOrCidr +
    SingleValue, a, b>(a: a, b: b) -> inet_same_family<T, U, a, b> where
    a: diesel::expression::AsExpression<T>,
    b: diesel::expression::AsExpression<U> {
    inet_same_family_utils::inet_same_family {
        a: a.as_expression(),
        b: b.as_expression(),
        T: ::std::marker::PhantomData,
        U: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`inet_same_family()`](fn@inet_same_family)"]
pub type inet_same_family<T, U, a, b> =
    inet_same_family_utils::inet_same_family<T, U,
    <a as diesel::expression::AsExpression<T>>::Expression,
    <b as diesel::expression::AsExpression<U>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod inet_same_family_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct inet_same_family<T, U, a, b> {
        pub(in super) a: a,
        pub(in super) b: b,
        pub(in super) T: ::std::marker::PhantomData<T>,
        pub(in super) U: ::std::marker::PhantomData<U>,
    }
    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, a, b, __Rhs> ::std::ops::Add<__Rhs> for
                inet_same_family<T, U, a, b> 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, a, b, __Rhs> ::std::ops::Sub<__Rhs> for
                inet_same_family<T, U, a, b> 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, a, b, __Rhs> ::std::ops::Mul<__Rhs> for
                inet_same_family<T, U, a, b> 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, a, b, __Rhs> ::std::ops::Div<__Rhs> for
                inet_same_family<T, U, a, b> 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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, U: ::core::fmt::Debug, a: ::core::fmt::Debug,
        b: ::core::fmt::Debug> ::core::fmt::Debug for
        inet_same_family<T, U, a, b> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "inet_same_family", "a", &self.a, "b", &self.b, "T", &self.T,
                "U", &&self.U)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, U: ::core::clone::Clone,
        a: ::core::clone::Clone, b: ::core::clone::Clone> ::core::clone::Clone
        for inet_same_family<T, U, a, b> {
        #[inline]
        fn clone(&self) -> inet_same_family<T, U, a, b> {
            inet_same_family {
                a: ::core::clone::Clone::clone(&self.a),
                b: ::core::clone::Clone::clone(&self.b),
                T: ::core::clone::Clone::clone(&self.T),
                U: ::core::clone::Clone::clone(&self.U),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, U: ::core::marker::Copy,
        a: ::core::marker::Copy, b: ::core::marker::Copy> ::core::marker::Copy
        for inet_same_family<T, U, a, b> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                U: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                b: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                inet_same_family<T, U, a, b> {
                type QueryId =
                    inet_same_family<<T as
                    diesel::query_builder::QueryId>::QueryId,
                    <U as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <b as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <U as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <b as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                    <U as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <b as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`inet_same_family()`](fn@inet_same_family)"]
    pub type HelperType<T, U, a, b> =
        inet_same_family<T, U, <a as AsExpression<T>>::Expression,
        <b as AsExpression<U>>::Expression>;
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b>
        Expression for inet_same_family<T, U, a, b> where (a, b): Expression {
        type SqlType = Bool;
    }
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        inet_same_family<T, U, a, b> where
        a: SelectableExpression<__DieselInternal>,
        b: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        inet_same_family<T, U, a, b> where
        a: AppearsOnTable<__DieselInternal>,
        b: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        inet_same_family<T, U, a, b> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>, b: QueryFragment<__DieselInternal>
        {
        const FUNCTION_NAME: &'static str = "inet_same_family";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.b.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.b.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b>
        QueryFragment<crate::pg::Pg> for inet_same_family<T, U, a, b> where
        a: QueryFragment<crate::pg::Pg>, b: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, b>(a, b);
    const _: () =
        {
            use diesel;
            impl<a, b, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, b> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                b: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<b
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<b as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue, a, b,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        inet_same_family<T, U, a, b> where
        __Derived<a, b>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, b> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the netmask length in bits."]
#[allow(non_camel_case_types)]
pub fn masklen<T: InetOrCidr + SingleValue, addr>(addr: addr)
    -> masklen<T, addr> where addr: diesel::expression::AsExpression<T> {
    masklen_utils::masklen {
        addr: addr.as_expression(),
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`masklen()`](fn@masklen)"]
pub type masklen<T, addr> =
    masklen_utils::masklen<T,
    <addr as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod masklen_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct masklen<T, addr> {
        pub(in super) addr: addr,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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, addr, __Rhs> ::std::ops::Add<__Rhs> for masklen<T, addr>
                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, addr, __Rhs> ::std::ops::Sub<__Rhs> for masklen<T, addr>
                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, addr, __Rhs> ::std::ops::Mul<__Rhs> for masklen<T, addr>
                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, addr, __Rhs> ::std::ops::Div<__Rhs> for masklen<T, addr>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, addr: ::core::fmt::Debug> ::core::fmt::Debug
        for masklen<T, addr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "masklen",
                "addr", &self.addr, "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, addr: ::core::clone::Clone>
        ::core::clone::Clone for masklen<T, addr> {
        #[inline]
        fn clone(&self) -> masklen<T, addr> {
            masklen {
                addr: ::core::clone::Clone::clone(&self.addr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, addr: ::core::marker::Copy>
        ::core::marker::Copy for masklen<T, addr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                addr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for masklen<T, addr> {
                type QueryId =
                    masklen<<T as diesel::query_builder::QueryId>::QueryId,
                    <addr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <addr as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <addr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`masklen()`](fn@masklen)"]
    pub type HelperType<T, addr> =
        masklen<T, <addr as AsExpression<T>>::Expression>;
    impl<T: InetOrCidr + SingleValue, addr> Expression for masklen<T, addr>
        where (addr): Expression {
        type SqlType = Integer;
    }
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        SelectableExpression<__DieselInternal> for masklen<T, addr> where
        addr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for masklen<T, addr> where
        addr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        FunctionFragment<__DieselInternal> for masklen<T, addr> where
        __DieselInternal: diesel::backend::Backend,
        addr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "masklen";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.addr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.addr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, addr> QueryFragment<crate::pg::Pg> for
        masklen<T, addr> where addr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<addr>(addr);
    const _: () =
        {
            use diesel;
            impl<addr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<addr> where
                addr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <addr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        ValidGrouping<__DieselInternal> for masklen<T, addr> where
        __Derived<addr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<addr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Computes the network mask for the address\'s network."]
#[allow(non_camel_case_types)]
pub fn netmask<T: InetOrCidr + SingleValue, addr>(addr: addr)
    -> netmask<T, addr> where addr: diesel::expression::AsExpression<T> {
    netmask_utils::netmask {
        addr: addr.as_expression(),
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`netmask()`](fn@netmask)"]
pub type netmask<T, addr> =
    netmask_utils::netmask<T,
    <addr as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod netmask_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct netmask<T, addr> {
        pub(in super) addr: addr,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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, addr, __Rhs> ::std::ops::Add<__Rhs> for netmask<T, addr>
                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, addr, __Rhs> ::std::ops::Sub<__Rhs> for netmask<T, addr>
                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, addr, __Rhs> ::std::ops::Mul<__Rhs> for netmask<T, addr>
                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, addr, __Rhs> ::std::ops::Div<__Rhs> for netmask<T, addr>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, addr: ::core::fmt::Debug> ::core::fmt::Debug
        for netmask<T, addr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "netmask",
                "addr", &self.addr, "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, addr: ::core::clone::Clone>
        ::core::clone::Clone for netmask<T, addr> {
        #[inline]
        fn clone(&self) -> netmask<T, addr> {
            netmask {
                addr: ::core::clone::Clone::clone(&self.addr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, addr: ::core::marker::Copy>
        ::core::marker::Copy for netmask<T, addr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                addr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for netmask<T, addr> {
                type QueryId =
                    netmask<<T as diesel::query_builder::QueryId>::QueryId,
                    <addr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <addr as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <addr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`netmask()`](fn@netmask)"]
    pub type HelperType<T, addr> =
        netmask<T, <addr as AsExpression<T>>::Expression>;
    impl<T: InetOrCidr + SingleValue, addr> Expression for netmask<T, addr>
        where (addr): Expression {
        type SqlType = Inet;
    }
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        SelectableExpression<__DieselInternal> for netmask<T, addr> where
        addr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for netmask<T, addr> where
        addr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        FunctionFragment<__DieselInternal> for netmask<T, addr> where
        __DieselInternal: diesel::backend::Backend,
        addr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "netmask";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.addr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.addr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, addr> QueryFragment<crate::pg::Pg> for
        netmask<T, addr> where addr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<addr>(addr);
    const _: () =
        {
            use diesel;
            impl<addr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<addr> where
                addr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <addr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        ValidGrouping<__DieselInternal> for netmask<T, addr> where
        __Derived<addr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<addr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Returns the network part of the address, zeroing out whatever is to the right of the"]
#[doc = " netmask. (This is equivalent to casting the value to cidr.)"]
#[allow(non_camel_case_types)]
pub fn network<T: InetOrCidr + SingleValue, addr>(addr: addr)
    -> network<T, addr> where addr: diesel::expression::AsExpression<T> {
    network_utils::network {
        addr: addr.as_expression(),
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`network()`](fn@network)"]
pub type network<T, addr> =
    network_utils::network<T,
    <addr as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod network_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct network<T, addr> {
        pub(in super) addr: addr,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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, addr, __Rhs> ::std::ops::Add<__Rhs> for network<T, addr>
                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, addr, __Rhs> ::std::ops::Sub<__Rhs> for network<T, addr>
                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, addr, __Rhs> ::std::ops::Mul<__Rhs> for network<T, addr>
                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, addr, __Rhs> ::std::ops::Div<__Rhs> for network<T, addr>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, addr: ::core::fmt::Debug> ::core::fmt::Debug
        for network<T, addr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "network",
                "addr", &self.addr, "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, addr: ::core::clone::Clone>
        ::core::clone::Clone for network<T, addr> {
        #[inline]
        fn clone(&self) -> network<T, addr> {
            network {
                addr: ::core::clone::Clone::clone(&self.addr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, addr: ::core::marker::Copy>
        ::core::marker::Copy for network<T, addr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                addr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for network<T, addr> {
                type QueryId =
                    network<<T as diesel::query_builder::QueryId>::QueryId,
                    <addr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <addr as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <addr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`network()`](fn@network)"]
    pub type HelperType<T, addr> =
        network<T, <addr as AsExpression<T>>::Expression>;
    impl<T: InetOrCidr + SingleValue, addr> Expression for network<T, addr>
        where (addr): Expression {
        type SqlType = Cidr;
    }
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        SelectableExpression<__DieselInternal> for network<T, addr> where
        addr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for network<T, addr> where
        addr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        FunctionFragment<__DieselInternal> for network<T, addr> where
        __DieselInternal: diesel::backend::Backend,
        addr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "network";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.addr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.addr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, addr> QueryFragment<crate::pg::Pg> for
        network<T, addr> where addr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<addr>(addr);
    const _: () =
        {
            use diesel;
            impl<addr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<addr> where
                addr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <addr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<T: InetOrCidr + SingleValue, addr, __DieselInternal>
        ValidGrouping<__DieselInternal> for network<T, addr> where
        __Derived<addr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<addr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Sets the netmask length for an inet or cidr value."]
#[doc =
" For inet, the address part does not changes. For cidr, address bits to the right of the new"]
#[doc = " netmask are set to zero."]
#[allow(non_camel_case_types)]
pub fn set_masklen<T: InetOrCidr + SingleValue, addr,
    len>(addr: addr, len: len) -> set_masklen<T, addr, len> where
    addr: diesel::expression::AsExpression<T>,
    len: diesel::expression::AsExpression<Integer> {
    set_masklen_utils::set_masklen {
        addr: addr.as_expression(),
        len: len.as_expression(),
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`set_masklen()`](fn@set_masklen)"]
pub type set_masklen<T, addr, len> =
    set_masklen_utils::set_masklen<T,
    <addr as diesel::expression::AsExpression<T>>::Expression,
    <len as diesel::expression::AsExpression<Integer>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod set_masklen_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct set_masklen<T, addr, len> {
        pub(in super) addr: addr,
        pub(in super) len: len,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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, addr, len, __Rhs> ::std::ops::Add<__Rhs> for
                set_masklen<T, addr, len> 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, addr, len, __Rhs> ::std::ops::Sub<__Rhs> for
                set_masklen<T, addr, len> 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, addr, len, __Rhs> ::std::ops::Mul<__Rhs> for
                set_masklen<T, addr, len> 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, addr, len, __Rhs> ::std::ops::Div<__Rhs> for
                set_masklen<T, addr, len> 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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, addr: ::core::fmt::Debug,
        len: ::core::fmt::Debug> ::core::fmt::Debug for
        set_masklen<T, addr, len> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f,
                "set_masklen", "addr", &self.addr, "len", &self.len, "T",
                &&self.T)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, addr: ::core::clone::Clone,
        len: ::core::clone::Clone> ::core::clone::Clone for
        set_masklen<T, addr, len> {
        #[inline]
        fn clone(&self) -> set_masklen<T, addr, len> {
            set_masklen {
                addr: ::core::clone::Clone::clone(&self.addr),
                len: ::core::clone::Clone::clone(&self.len),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, addr: ::core::marker::Copy,
        len: ::core::marker::Copy> ::core::marker::Copy for
        set_masklen<T, addr, len> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                addr: diesel::query_builder::QueryId,
                len: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for set_masklen<T, addr, len> {
                type QueryId =
                    set_masklen<<T as diesel::query_builder::QueryId>::QueryId,
                    <addr as diesel::query_builder::QueryId>::QueryId,
                    <len as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <addr as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <len as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <addr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <len as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`set_masklen()`](fn@set_masklen)"]
    pub type HelperType<T, addr, len> =
        set_masklen<T, <addr as AsExpression<T>>::Expression,
        <len as AsExpression<Integer>>::Expression>;
    impl<T: InetOrCidr + SingleValue, addr, len> Expression for
        set_masklen<T, addr, len> where (addr, len): Expression {
        type SqlType = T;
    }
    impl<T: InetOrCidr + SingleValue, addr, len, __DieselInternal>
        SelectableExpression<__DieselInternal> for set_masklen<T, addr, len>
        where addr: SelectableExpression<__DieselInternal>,
        len: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: InetOrCidr + SingleValue, addr, len, __DieselInternal>
        AppearsOnTable<__DieselInternal> for set_masklen<T, addr, len> where
        addr: AppearsOnTable<__DieselInternal>,
        len: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: InetOrCidr + SingleValue, addr, len, __DieselInternal>
        FunctionFragment<__DieselInternal> for set_masklen<T, addr, len> where
        __DieselInternal: diesel::backend::Backend,
        addr: QueryFragment<__DieselInternal>,
        len: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "set_masklen";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.addr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.addr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.len.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.len.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: InetOrCidr + SingleValue, addr, len> QueryFragment<crate::pg::Pg>
        for set_masklen<T, addr, len> where
        addr: QueryFragment<crate::pg::Pg>, len: QueryFragment<crate::pg::Pg>
        {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<addr, len>(addr, len);
    const _: () =
        {
            use diesel;
            impl<addr, len, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<addr, len> where
                addr: diesel::expression::ValidGrouping<__GroupByClause>,
                len: diesel::expression::ValidGrouping<__GroupByClause>,
                <addr as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<len
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<addr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<len as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<T: InetOrCidr + SingleValue, addr, len, __DieselInternal>
        ValidGrouping<__DieselInternal> for set_masklen<T, addr, len> where
        __Derived<addr, len>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<addr, len> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the lower bound of the range"]
#[doc = ""]
#[doc = " If the range is empty or has no lower bound, it returns NULL."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " # use diesel::pg::sql_types::{Range, Multirange};"]
#[doc = " # use diesel::dsl::lower;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let int = diesel::select(lower::<Range<_>, _>(1..2)).get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(1), int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(lower::<Range<_>, _>(..2)).get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(lower::<Nullable<Range<_>>, _>(None::<std::ops::Range<i32>>))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc = " let int = diesel::select(lower::<Multirange<_>, _>(vec![5..7]))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(5), int);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn lower<R: MultirangeOrRangeMaybeNullable + SingleValue,
    range>(range: range) -> lower<R, range> where
    range: diesel::expression::AsExpression<R> {
    lower_utils::lower {
        range: range.as_expression(),
        R: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`lower()`](fn@lower)"]
pub type lower<R, range> =
    lower_utils::lower<R,
    <range as diesel::expression::AsExpression<R>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod lower_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct lower<R, range> {
        pub(in super) range: range,
        pub(in super) R: ::std::marker::PhantomData<R>,
    }
    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<R, range, __Rhs> ::std::ops::Add<__Rhs> for lower<R, range>
                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<R, range, __Rhs> ::std::ops::Sub<__Rhs> for lower<R, range>
                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<R, range, __Rhs> ::std::ops::Mul<__Rhs> for lower<R, range>
                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<R, range, __Rhs> ::std::ops::Div<__Rhs> for lower<R, range>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<R: ::core::fmt::Debug, range: ::core::fmt::Debug> ::core::fmt::Debug
        for lower<R, range> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "lower",
                "range", &self.range, "R", &&self.R)
        }
    }
    #[automatically_derived]
    impl<R: ::core::clone::Clone, range: ::core::clone::Clone>
        ::core::clone::Clone for lower<R, range> {
        #[inline]
        fn clone(&self) -> lower<R, range> {
            lower {
                range: ::core::clone::Clone::clone(&self.range),
                R: ::core::clone::Clone::clone(&self.R),
            }
        }
    }
    #[automatically_derived]
    impl<R: ::core::marker::Copy, range: ::core::marker::Copy>
        ::core::marker::Copy for lower<R, range> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R: diesel::query_builder::QueryId,
                range: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for lower<R, range> {
                type QueryId =
                    lower<<R as diesel::query_builder::QueryId>::QueryId,
                    <range as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <range as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <R as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <range as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`lower()`](fn@lower)"]
    pub type HelperType<R, range> =
        lower<R, <range as AsExpression<R>>::Expression>;
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range> Expression
        for lower<R, range> where (range): Expression {
        type SqlType = Nullable<R::Inner>;
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        lower<R, range> where range: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range,
        __DieselInternal> AppearsOnTable<__DieselInternal> for lower<R, range>
        where range: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        lower<R, range> where __DieselInternal: diesel::backend::Backend,
        range: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "lower";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.range.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.range.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range>
        QueryFragment<crate::pg::Pg> for lower<R, range> where
        range: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<range>(range);
    const _: () =
        {
            use diesel;
            impl<range, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<range> where
                range: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <range as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range,
        __DieselInternal> ValidGrouping<__DieselInternal> for lower<R, range>
        where __Derived<range>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<range> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the upper bound of the range"]
#[doc = ""]
#[doc = " If the range is empty or has no upper bound, it returns NULL."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " # use diesel::pg::sql_types::{Range, Multirange};"]
#[doc = " # use diesel::dsl::upper;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let int = diesel::select(upper::<Range<_>, _>(1..2)).get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(2), int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(upper::<Range<_>, _>(1..)).get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(upper::<Nullable<Range<_>>, _>(None::<std::ops::Range<i32>>))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc = " let int = diesel::select(upper::<Multirange<_>, _>(vec![5..7]))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(7), int);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn upper<R: MultirangeOrRangeMaybeNullable + SingleValue,
    range>(range: range) -> upper<R, range> where
    range: diesel::expression::AsExpression<R> {
    upper_utils::upper {
        range: range.as_expression(),
        R: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`upper()`](fn@upper)"]
pub type upper<R, range> =
    upper_utils::upper<R,
    <range as diesel::expression::AsExpression<R>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod upper_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct upper<R, range> {
        pub(in super) range: range,
        pub(in super) R: ::std::marker::PhantomData<R>,
    }
    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<R, range, __Rhs> ::std::ops::Add<__Rhs> for upper<R, range>
                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<R, range, __Rhs> ::std::ops::Sub<__Rhs> for upper<R, range>
                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<R, range, __Rhs> ::std::ops::Mul<__Rhs> for upper<R, range>
                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<R, range, __Rhs> ::std::ops::Div<__Rhs> for upper<R, range>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<R: ::core::fmt::Debug, range: ::core::fmt::Debug> ::core::fmt::Debug
        for upper<R, range> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "upper",
                "range", &self.range, "R", &&self.R)
        }
    }
    #[automatically_derived]
    impl<R: ::core::clone::Clone, range: ::core::clone::Clone>
        ::core::clone::Clone for upper<R, range> {
        #[inline]
        fn clone(&self) -> upper<R, range> {
            upper {
                range: ::core::clone::Clone::clone(&self.range),
                R: ::core::clone::Clone::clone(&self.R),
            }
        }
    }
    #[automatically_derived]
    impl<R: ::core::marker::Copy, range: ::core::marker::Copy>
        ::core::marker::Copy for upper<R, range> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R: diesel::query_builder::QueryId,
                range: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for upper<R, range> {
                type QueryId =
                    upper<<R as diesel::query_builder::QueryId>::QueryId,
                    <range as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <range as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <R as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <range as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`upper()`](fn@upper)"]
    pub type HelperType<R, range> =
        upper<R, <range as AsExpression<R>>::Expression>;
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range> Expression
        for upper<R, range> where (range): Expression {
        type SqlType = Nullable<R::Inner>;
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        upper<R, range> where range: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range,
        __DieselInternal> AppearsOnTable<__DieselInternal> for upper<R, range>
        where range: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        upper<R, range> where __DieselInternal: diesel::backend::Backend,
        range: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "upper";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.range.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.range.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range>
        QueryFragment<crate::pg::Pg> for upper<R, range> where
        range: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<range>(range);
    const _: () =
        {
            use diesel;
            impl<range, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<range> where
                range: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <range as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue, range,
        __DieselInternal> ValidGrouping<__DieselInternal> for upper<R, range>
        where __Derived<range>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<range> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns true if the range is empty"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " # use diesel::pg::sql_types::{Range, Multirange};"]
#[doc = " # use diesel::dsl::isempty;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let int = diesel::select(isempty::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(false, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(isempty::<Range<Integer>, _>(1..1)).get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(true, int);"]
#[doc = ""]
#[doc = " let int = diesel::select(isempty::<Nullable<Range<Integer>>, _>("]
#[doc = "     None::<std::ops::Range<i32>>,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<bool>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(isempty::<Multirange<Integer>, _>(vec![5..7]))"]
#[doc = "     .get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(false, int);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn isempty<R: MultirangeOrRangeMaybeNullable + SingleValue +
    MaybeNullableValue<Bool>, range>(range: range) -> isempty<R, range> where
    range: diesel::expression::AsExpression<R> {
    isempty_utils::isempty {
        range: range.as_expression(),
        R: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`isempty()`](fn@isempty)"]
pub type isempty<R, range> =
    isempty_utils::isempty<R,
    <range as diesel::expression::AsExpression<R>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod isempty_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct isempty<R, range> {
        pub(in super) range: range,
        pub(in super) R: ::std::marker::PhantomData<R>,
    }
    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<R, range, __Rhs> ::std::ops::Add<__Rhs> for isempty<R, range>
                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<R, range, __Rhs> ::std::ops::Sub<__Rhs> for isempty<R, range>
                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<R, range, __Rhs> ::std::ops::Mul<__Rhs> for isempty<R, range>
                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<R, range, __Rhs> ::std::ops::Div<__Rhs> for isempty<R, range>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<R: ::core::fmt::Debug, range: ::core::fmt::Debug> ::core::fmt::Debug
        for isempty<R, range> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "isempty",
                "range", &self.range, "R", &&self.R)
        }
    }
    #[automatically_derived]
    impl<R: ::core::clone::Clone, range: ::core::clone::Clone>
        ::core::clone::Clone for isempty<R, range> {
        #[inline]
        fn clone(&self) -> isempty<R, range> {
            isempty {
                range: ::core::clone::Clone::clone(&self.range),
                R: ::core::clone::Clone::clone(&self.R),
            }
        }
    }
    #[automatically_derived]
    impl<R: ::core::marker::Copy, range: ::core::marker::Copy>
        ::core::marker::Copy for isempty<R, range> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R: diesel::query_builder::QueryId,
                range: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for isempty<R, range> {
                type QueryId =
                    isempty<<R as diesel::query_builder::QueryId>::QueryId,
                    <range as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <range as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <R as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <range as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`isempty()`](fn@isempty)"]
    pub type HelperType<R, range> =
        isempty<R, <range as AsExpression<R>>::Expression>;
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> Expression for isempty<R, range>
        where (range): Expression {
        type SqlType = R::Out;
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        SelectableExpression<__DieselInternal> for isempty<R, range> where
        range: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        AppearsOnTable<__DieselInternal> for isempty<R, range> where
        range: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        FunctionFragment<__DieselInternal> for isempty<R, range> where
        __DieselInternal: diesel::backend::Backend,
        range: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "isempty";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.range.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.range.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> QueryFragment<crate::pg::Pg> for
        isempty<R, range> where range: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<range>(range);
    const _: () =
        {
            use diesel;
            impl<range, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<range> where
                range: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <range as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        ValidGrouping<__DieselInternal> for isempty<R, range> where
        __Derived<range>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<range> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns true if the range\'s lower bound is inclusive"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " # use diesel::pg::sql_types::{Range, Multirange};"]
#[doc = " # use diesel::dsl::lower_inc;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = " let int ="]
#[doc =
"     diesel::select(lower_inc::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(true, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(lower_inc::<Range<Integer>, _>(..5)).get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(false, int);"]
#[doc = ""]
#[doc = " let int = diesel::select(lower_inc::<Nullable<Range<Integer>>, _>("]
#[doc = "     None::<std::ops::Range<i32>>,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<bool>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(lower_inc::<Multirange<Integer>, _>(vec![5..7]))"]
#[doc = "     .get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(true, int);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn lower_inc<R: MultirangeOrRangeMaybeNullable + SingleValue +
    MaybeNullableValue<Bool>, range>(range: range) -> lower_inc<R, range>
    where range: diesel::expression::AsExpression<R> {
    lower_inc_utils::lower_inc {
        range: range.as_expression(),
        R: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`lower_inc()`](fn@lower_inc)"]
pub type lower_inc<R, range> =
    lower_inc_utils::lower_inc<R,
    <range as diesel::expression::AsExpression<R>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod lower_inc_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct lower_inc<R, range> {
        pub(in super) range: range,
        pub(in super) R: ::std::marker::PhantomData<R>,
    }
    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<R, range, __Rhs> ::std::ops::Add<__Rhs> for
                lower_inc<R, range> 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<R, range, __Rhs> ::std::ops::Sub<__Rhs> for
                lower_inc<R, range> 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<R, range, __Rhs> ::std::ops::Mul<__Rhs> for
                lower_inc<R, range> 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<R, range, __Rhs> ::std::ops::Div<__Rhs> for
                lower_inc<R, range> 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())
                }
            }
        };
    #[automatically_derived]
    impl<R: ::core::fmt::Debug, range: ::core::fmt::Debug> ::core::fmt::Debug
        for lower_inc<R, range> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "lower_inc",
                "range", &self.range, "R", &&self.R)
        }
    }
    #[automatically_derived]
    impl<R: ::core::clone::Clone, range: ::core::clone::Clone>
        ::core::clone::Clone for lower_inc<R, range> {
        #[inline]
        fn clone(&self) -> lower_inc<R, range> {
            lower_inc {
                range: ::core::clone::Clone::clone(&self.range),
                R: ::core::clone::Clone::clone(&self.R),
            }
        }
    }
    #[automatically_derived]
    impl<R: ::core::marker::Copy, range: ::core::marker::Copy>
        ::core::marker::Copy for lower_inc<R, range> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R: diesel::query_builder::QueryId,
                range: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for lower_inc<R, range> {
                type QueryId =
                    lower_inc<<R as diesel::query_builder::QueryId>::QueryId,
                    <range as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <range as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <R as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <range as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`lower_inc()`](fn@lower_inc)"]
    pub type HelperType<R, range> =
        lower_inc<R, <range as AsExpression<R>>::Expression>;
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> Expression for lower_inc<R, range>
        where (range): Expression {
        type SqlType = R::Out;
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        SelectableExpression<__DieselInternal> for lower_inc<R, range> where
        range: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        AppearsOnTable<__DieselInternal> for lower_inc<R, range> where
        range: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        FunctionFragment<__DieselInternal> for lower_inc<R, range> where
        __DieselInternal: diesel::backend::Backend,
        range: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "lower_inc";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.range.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.range.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> QueryFragment<crate::pg::Pg> for
        lower_inc<R, range> where range: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<range>(range);
    const _: () =
        {
            use diesel;
            impl<range, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<range> where
                range: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <range as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        ValidGrouping<__DieselInternal> for lower_inc<R, range> where
        __Derived<range>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<range> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns true if the range\'s upper bound is inclusive"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " # use diesel::pg::sql_types::{Range, Multirange};"]
#[doc = " # use diesel::dsl::upper_inc;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = " let int ="]
#[doc =
"     diesel::select(upper_inc::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(false, int);"]
#[doc = ""]
#[doc = " let int = diesel::select(upper_inc::<Nullable<Range<Integer>>, _>("]
#[doc = "     None::<std::ops::Range<i32>>,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<bool>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(upper_inc::<Multirange<Integer>, _>(vec![5..7]))"]
#[doc = "     .get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(false, int);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn upper_inc<R: MultirangeOrRangeMaybeNullable + SingleValue +
    MaybeNullableValue<Bool>, range>(range: range) -> upper_inc<R, range>
    where range: diesel::expression::AsExpression<R> {
    upper_inc_utils::upper_inc {
        range: range.as_expression(),
        R: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`upper_inc()`](fn@upper_inc)"]
pub type upper_inc<R, range> =
    upper_inc_utils::upper_inc<R,
    <range as diesel::expression::AsExpression<R>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod upper_inc_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct upper_inc<R, range> {
        pub(in super) range: range,
        pub(in super) R: ::std::marker::PhantomData<R>,
    }
    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<R, range, __Rhs> ::std::ops::Add<__Rhs> for
                upper_inc<R, range> 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<R, range, __Rhs> ::std::ops::Sub<__Rhs> for
                upper_inc<R, range> 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<R, range, __Rhs> ::std::ops::Mul<__Rhs> for
                upper_inc<R, range> 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<R, range, __Rhs> ::std::ops::Div<__Rhs> for
                upper_inc<R, range> 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())
                }
            }
        };
    #[automatically_derived]
    impl<R: ::core::fmt::Debug, range: ::core::fmt::Debug> ::core::fmt::Debug
        for upper_inc<R, range> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "upper_inc",
                "range", &self.range, "R", &&self.R)
        }
    }
    #[automatically_derived]
    impl<R: ::core::clone::Clone, range: ::core::clone::Clone>
        ::core::clone::Clone for upper_inc<R, range> {
        #[inline]
        fn clone(&self) -> upper_inc<R, range> {
            upper_inc {
                range: ::core::clone::Clone::clone(&self.range),
                R: ::core::clone::Clone::clone(&self.R),
            }
        }
    }
    #[automatically_derived]
    impl<R: ::core::marker::Copy, range: ::core::marker::Copy>
        ::core::marker::Copy for upper_inc<R, range> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R: diesel::query_builder::QueryId,
                range: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for upper_inc<R, range> {
                type QueryId =
                    upper_inc<<R as diesel::query_builder::QueryId>::QueryId,
                    <range as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <range as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <R as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <range as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`upper_inc()`](fn@upper_inc)"]
    pub type HelperType<R, range> =
        upper_inc<R, <range as AsExpression<R>>::Expression>;
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> Expression for upper_inc<R, range>
        where (range): Expression {
        type SqlType = R::Out;
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        SelectableExpression<__DieselInternal> for upper_inc<R, range> where
        range: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        AppearsOnTable<__DieselInternal> for upper_inc<R, range> where
        range: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        FunctionFragment<__DieselInternal> for upper_inc<R, range> where
        __DieselInternal: diesel::backend::Backend,
        range: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "upper_inc";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.range.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.range.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> QueryFragment<crate::pg::Pg> for
        upper_inc<R, range> where range: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<range>(range);
    const _: () =
        {
            use diesel;
            impl<range, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<range> where
                range: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <range as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        ValidGrouping<__DieselInternal> for upper_inc<R, range> where
        __Derived<range>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<range> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns true if the range\'s lower bound is unbounded"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " # use diesel::pg::sql_types::{Range, Multirange};"]
#[doc = " # use diesel::dsl::lower_inf;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = " let int ="]
#[doc =
"     diesel::select(lower_inf::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(false, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(lower_inf::<Range<Integer>, _>(..5)).get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(true, int);"]
#[doc = ""]
#[doc = " let int = diesel::select(lower_inf::<Nullable<Range<Integer>>, _>("]
#[doc = "     None::<std::ops::Range<i32>>,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<bool>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(lower_inf::<Multirange<Integer>, _>(vec![5..7]))"]
#[doc = "     .get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(false, int);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn lower_inf<R: MultirangeOrRangeMaybeNullable + SingleValue +
    MaybeNullableValue<Bool>, range>(range: range) -> lower_inf<R, range>
    where range: diesel::expression::AsExpression<R> {
    lower_inf_utils::lower_inf {
        range: range.as_expression(),
        R: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`lower_inf()`](fn@lower_inf)"]
pub type lower_inf<R, range> =
    lower_inf_utils::lower_inf<R,
    <range as diesel::expression::AsExpression<R>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod lower_inf_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct lower_inf<R, range> {
        pub(in super) range: range,
        pub(in super) R: ::std::marker::PhantomData<R>,
    }
    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<R, range, __Rhs> ::std::ops::Add<__Rhs> for
                lower_inf<R, range> 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<R, range, __Rhs> ::std::ops::Sub<__Rhs> for
                lower_inf<R, range> 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<R, range, __Rhs> ::std::ops::Mul<__Rhs> for
                lower_inf<R, range> 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<R, range, __Rhs> ::std::ops::Div<__Rhs> for
                lower_inf<R, range> 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())
                }
            }
        };
    #[automatically_derived]
    impl<R: ::core::fmt::Debug, range: ::core::fmt::Debug> ::core::fmt::Debug
        for lower_inf<R, range> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "lower_inf",
                "range", &self.range, "R", &&self.R)
        }
    }
    #[automatically_derived]
    impl<R: ::core::clone::Clone, range: ::core::clone::Clone>
        ::core::clone::Clone for lower_inf<R, range> {
        #[inline]
        fn clone(&self) -> lower_inf<R, range> {
            lower_inf {
                range: ::core::clone::Clone::clone(&self.range),
                R: ::core::clone::Clone::clone(&self.R),
            }
        }
    }
    #[automatically_derived]
    impl<R: ::core::marker::Copy, range: ::core::marker::Copy>
        ::core::marker::Copy for lower_inf<R, range> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R: diesel::query_builder::QueryId,
                range: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for lower_inf<R, range> {
                type QueryId =
                    lower_inf<<R as diesel::query_builder::QueryId>::QueryId,
                    <range as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <range as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <R as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <range as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`lower_inf()`](fn@lower_inf)"]
    pub type HelperType<R, range> =
        lower_inf<R, <range as AsExpression<R>>::Expression>;
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> Expression for lower_inf<R, range>
        where (range): Expression {
        type SqlType = R::Out;
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        SelectableExpression<__DieselInternal> for lower_inf<R, range> where
        range: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        AppearsOnTable<__DieselInternal> for lower_inf<R, range> where
        range: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        FunctionFragment<__DieselInternal> for lower_inf<R, range> where
        __DieselInternal: diesel::backend::Backend,
        range: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "lower_inf";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.range.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.range.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> QueryFragment<crate::pg::Pg> for
        lower_inf<R, range> where range: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<range>(range);
    const _: () =
        {
            use diesel;
            impl<range, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<range> where
                range: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <range as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        ValidGrouping<__DieselInternal> for lower_inf<R, range> where
        __Derived<range>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<range> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns true if the range\'s upper bound is unbounded"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " # use diesel::pg::sql_types::{Range, Multirange};"]
#[doc = " # use diesel::dsl::upper_inf;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = " let int ="]
#[doc =
"     diesel::select(upper_inf::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(false, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(upper_inf::<Range<Integer>, _>(1..)).get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(true, int);"]
#[doc = ""]
#[doc = " let int = diesel::select(upper_inf::<Nullable<Range<Integer>>, _>("]
#[doc = "     None::<std::ops::Range<i32>>,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<bool>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(upper_inf::<Multirange<Integer>, _>(vec![5..7]))"]
#[doc = "     .get_result::<bool>(connection)?;"]
#[doc = " assert_eq!(false, int);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn upper_inf<R: MultirangeOrRangeMaybeNullable + SingleValue +
    MaybeNullableValue<Bool>, range>(range: range) -> upper_inf<R, range>
    where range: diesel::expression::AsExpression<R> {
    upper_inf_utils::upper_inf {
        range: range.as_expression(),
        R: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`upper_inf()`](fn@upper_inf)"]
pub type upper_inf<R, range> =
    upper_inf_utils::upper_inf<R,
    <range as diesel::expression::AsExpression<R>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod upper_inf_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct upper_inf<R, range> {
        pub(in super) range: range,
        pub(in super) R: ::std::marker::PhantomData<R>,
    }
    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<R, range, __Rhs> ::std::ops::Add<__Rhs> for
                upper_inf<R, range> 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<R, range, __Rhs> ::std::ops::Sub<__Rhs> for
                upper_inf<R, range> 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<R, range, __Rhs> ::std::ops::Mul<__Rhs> for
                upper_inf<R, range> 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<R, range, __Rhs> ::std::ops::Div<__Rhs> for
                upper_inf<R, range> 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())
                }
            }
        };
    #[automatically_derived]
    impl<R: ::core::fmt::Debug, range: ::core::fmt::Debug> ::core::fmt::Debug
        for upper_inf<R, range> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "upper_inf",
                "range", &self.range, "R", &&self.R)
        }
    }
    #[automatically_derived]
    impl<R: ::core::clone::Clone, range: ::core::clone::Clone>
        ::core::clone::Clone for upper_inf<R, range> {
        #[inline]
        fn clone(&self) -> upper_inf<R, range> {
            upper_inf {
                range: ::core::clone::Clone::clone(&self.range),
                R: ::core::clone::Clone::clone(&self.R),
            }
        }
    }
    #[automatically_derived]
    impl<R: ::core::marker::Copy, range: ::core::marker::Copy>
        ::core::marker::Copy for upper_inf<R, range> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R: diesel::query_builder::QueryId,
                range: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for upper_inf<R, range> {
                type QueryId =
                    upper_inf<<R as diesel::query_builder::QueryId>::QueryId,
                    <range as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <range as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <R as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <range as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`upper_inf()`](fn@upper_inf)"]
    pub type HelperType<R, range> =
        upper_inf<R, <range as AsExpression<R>>::Expression>;
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> Expression for upper_inf<R, range>
        where (range): Expression {
        type SqlType = R::Out;
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        SelectableExpression<__DieselInternal> for upper_inf<R, range> where
        range: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        AppearsOnTable<__DieselInternal> for upper_inf<R, range> where
        range: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        FunctionFragment<__DieselInternal> for upper_inf<R, range> where
        __DieselInternal: diesel::backend::Backend,
        range: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "upper_inf";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.range.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.range.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range> QueryFragment<crate::pg::Pg> for
        upper_inf<R, range> where range: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<range>(range);
    const _: () =
        {
            use diesel;
            impl<range, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<range> where
                range: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <range as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<R: MultirangeOrRangeMaybeNullable + SingleValue +
        MaybeNullableValue<Bool>, range, __DieselInternal>
        ValidGrouping<__DieselInternal> for upper_inf<R, range> where
        __Derived<range>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<range> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the smallest range which includes both of the given ranges"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " # use diesel::pg::sql_types::{Range, Multirange};"]
#[doc = " # use diesel::dsl::range_merge;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let int = diesel::select(range_merge::<Range<Integer>, Range<_>, _, _>(5..11, 10..))"]
#[doc = "     .get_result::<(Bound<i32>, Bound<i32>)>(connection)?;"]
#[doc = " assert_eq!((Bound::Included(5), Bound::Unbounded), int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(range_merge::<Range<Integer>, Range<_>, _, _>(1..3, 7..10))"]
#[doc = "     .get_result::<(Bound<i32>, Bound<i32>)>(connection)?;"]
#[doc = " assert_eq!((Bound::Included(1), Bound::Excluded(10)), int);"]
#[doc = ""]
#[doc = " let int = diesel::select(range_merge::<"]
#[doc = "     Nullable<Range<Integer>>,"]
#[doc = "     Nullable<Range<_>>,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = " >(None::<std::ops::Range<i32>>, 7..10))"]
#[doc = " .get_result::<Option<(Bound<i32>, Bound<i32>)>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = ""]
#[doc = " let int = diesel::select(range_merge::<"]
#[doc = "     Nullable<Range<Integer>>,"]
#[doc = "     Nullable<Range<_>>,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = " >(1..3, None::<std::ops::Range<i32>>))"]
#[doc = " .get_result::<Option<(Bound<i32>, Bound<i32>)>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn range_merge<R1: RangeOrNullableRange + SingleValue,
    R2: RangeOrNullableRange<Inner = R1::Inner> + SingleValue +
    CombinedNullableValue<R1, Range<R1::Inner>>, lhs, rhs>(lhs: lhs, rhs: rhs)
    -> range_merge<R1, R2, lhs, rhs> where
    lhs: diesel::expression::AsExpression<R1>,
    rhs: diesel::expression::AsExpression<R2> {
    range_merge_utils::range_merge {
        lhs: lhs.as_expression(),
        rhs: rhs.as_expression(),
        R1: ::std::marker::PhantomData,
        R2: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`range_merge()`](fn@range_merge)"]
pub type range_merge<R1, R2, lhs, rhs> =
    range_merge_utils::range_merge<R1, R2,
    <lhs as diesel::expression::AsExpression<R1>>::Expression,
    <rhs as diesel::expression::AsExpression<R2>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod range_merge_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct range_merge<R1, R2, lhs, rhs> {
        pub(in super) lhs: lhs,
        pub(in super) rhs: rhs,
        pub(in super) R1: ::std::marker::PhantomData<R1>,
        pub(in super) R2: ::std::marker::PhantomData<R2>,
    }
    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<R1, R2, lhs, rhs, __Rhs> ::std::ops::Add<__Rhs> for
                range_merge<R1, R2, lhs, rhs> 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<R1, R2, lhs, rhs, __Rhs> ::std::ops::Sub<__Rhs> for
                range_merge<R1, R2, lhs, rhs> 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<R1, R2, lhs, rhs, __Rhs> ::std::ops::Mul<__Rhs> for
                range_merge<R1, R2, lhs, rhs> 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<R1, R2, lhs, rhs, __Rhs> ::std::ops::Div<__Rhs> for
                range_merge<R1, R2, lhs, rhs> 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())
                }
            }
        };
    #[automatically_derived]
    impl<R1: ::core::fmt::Debug, R2: ::core::fmt::Debug,
        lhs: ::core::fmt::Debug, rhs: ::core::fmt::Debug> ::core::fmt::Debug
        for range_merge<R1, R2, lhs, rhs> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "range_merge", "lhs", &self.lhs, "rhs", &self.rhs, "R1",
                &self.R1, "R2", &&self.R2)
        }
    }
    #[automatically_derived]
    impl<R1: ::core::clone::Clone, R2: ::core::clone::Clone,
        lhs: ::core::clone::Clone, rhs: ::core::clone::Clone>
        ::core::clone::Clone for range_merge<R1, R2, lhs, rhs> {
        #[inline]
        fn clone(&self) -> range_merge<R1, R2, lhs, rhs> {
            range_merge {
                lhs: ::core::clone::Clone::clone(&self.lhs),
                rhs: ::core::clone::Clone::clone(&self.rhs),
                R1: ::core::clone::Clone::clone(&self.R1),
                R2: ::core::clone::Clone::clone(&self.R2),
            }
        }
    }
    #[automatically_derived]
    impl<R1: ::core::marker::Copy, R2: ::core::marker::Copy,
        lhs: ::core::marker::Copy, rhs: ::core::marker::Copy>
        ::core::marker::Copy for range_merge<R1, R2, lhs, rhs> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R1: diesel::query_builder::QueryId,
                R2: diesel::query_builder::QueryId,
                lhs: diesel::query_builder::QueryId,
                rhs: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                range_merge<R1, R2, lhs, rhs> {
                type QueryId =
                    range_merge<<R1 as diesel::query_builder::QueryId>::QueryId,
                    <R2 as diesel::query_builder::QueryId>::QueryId,
                    <lhs as diesel::query_builder::QueryId>::QueryId,
                    <rhs as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <R2 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <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 =
                    <R1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    ||
                                    <R2 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <lhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <rhs as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`range_merge()`](fn@range_merge)"]
    pub type HelperType<R1, R2, lhs, rhs> =
        range_merge<R1, R2, <lhs as AsExpression<R1>>::Expression,
        <rhs as AsExpression<R2>>::Expression>;
    impl<R1: RangeOrNullableRange + SingleValue,
        R2: RangeOrNullableRange<Inner = R1::Inner> + SingleValue +
        CombinedNullableValue<R1, Range<R1::Inner>>, lhs, rhs> Expression for
        range_merge<R1, R2, lhs, rhs> where (lhs, rhs): Expression {
        type SqlType = R2::Out;
    }
    impl<R1: RangeOrNullableRange + SingleValue,
        R2: RangeOrNullableRange<Inner = R1::Inner> + SingleValue +
        CombinedNullableValue<R1, Range<R1::Inner>>, lhs, rhs,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        range_merge<R1, R2, lhs, rhs> where
        lhs: SelectableExpression<__DieselInternal>,
        rhs: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R1: RangeOrNullableRange + SingleValue,
        R2: RangeOrNullableRange<Inner = R1::Inner> + SingleValue +
        CombinedNullableValue<R1, Range<R1::Inner>>, lhs, rhs,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        range_merge<R1, R2, lhs, rhs> where
        lhs: AppearsOnTable<__DieselInternal>,
        rhs: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<R1: RangeOrNullableRange + SingleValue,
        R2: RangeOrNullableRange<Inner = R1::Inner> + SingleValue +
        CombinedNullableValue<R1, Range<R1::Inner>>, lhs, rhs,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        range_merge<R1, R2, lhs, rhs> where
        __DieselInternal: diesel::backend::Backend,
        lhs: QueryFragment<__DieselInternal>,
        rhs: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "range_merge";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.lhs.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.lhs.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.rhs.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.rhs.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R1: RangeOrNullableRange + SingleValue,
        R2: RangeOrNullableRange<Inner = R1::Inner> + SingleValue +
        CombinedNullableValue<R1, Range<R1::Inner>>, lhs, rhs>
        QueryFragment<crate::pg::Pg> for range_merge<R1, R2, lhs, rhs> where
        lhs: QueryFragment<crate::pg::Pg>, rhs: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<lhs, rhs>(lhs, rhs);
    const _: () =
        {
            use diesel;
            impl<lhs, rhs, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<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<R1: RangeOrNullableRange + SingleValue,
        R2: RangeOrNullableRange<Inner = R1::Inner> + SingleValue +
        CombinedNullableValue<R1, Range<R1::Inner>>, lhs, rhs,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        range_merge<R1, R2, lhs, rhs> where
        __Derived<lhs, rhs>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<lhs, rhs> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Returns the smallest range which includes all ranges in the multirange"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " # use diesel::pg::sql_types::{Range, Multirange};"]
#[doc = " # use diesel::dsl::multirange_merge;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let int = diesel::select(multirange_merge::<Multirange<Integer>, _>(vec!["]
#[doc = "     1..3,"]
#[doc = "     7..10,"]
#[doc = " ]))"]
#[doc = " .get_result::<(Bound<i32>, Bound<i32>)>(connection)?;"]
#[doc = " assert_eq!((Bound::Included(1), Bound::Excluded(10)), int);"]
#[doc = ""]
#[doc =
" let int = diesel::select(multirange_merge::<Nullable<Multirange<Integer>>, _>("]
#[doc = "     None::<Vec<std::ops::Range<i32>>>,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<(Bound<i32>, Bound<i32>)>>(connection)?;"]
#[doc = " assert_eq!(None, int);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn multirange_merge<R: MultirangeOrNullableMultirange + SingleValue,
    multirange>(multirange: multirange) -> multirange_merge<R, multirange>
    where multirange: diesel::expression::AsExpression<R> {
    multirange_merge_utils::multirange_merge {
        multirange: multirange.as_expression(),
        R: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`multirange_merge()`](fn@multirange_merge)"]
pub type multirange_merge<R, multirange> =
    multirange_merge_utils::multirange_merge<R,
    <multirange as diesel::expression::AsExpression<R>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod multirange_merge_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct multirange_merge<R, multirange> {
        pub(in super) multirange: multirange,
        pub(in super) R: ::std::marker::PhantomData<R>,
    }
    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<R, multirange, __Rhs> ::std::ops::Add<__Rhs> for
                multirange_merge<R, multirange> 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<R, multirange, __Rhs> ::std::ops::Sub<__Rhs> for
                multirange_merge<R, multirange> 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<R, multirange, __Rhs> ::std::ops::Mul<__Rhs> for
                multirange_merge<R, multirange> 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<R, multirange, __Rhs> ::std::ops::Div<__Rhs> for
                multirange_merge<R, multirange> 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())
                }
            }
        };
    #[automatically_derived]
    impl<R: ::core::fmt::Debug, multirange: ::core::fmt::Debug>
        ::core::fmt::Debug for multirange_merge<R, multirange> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "multirange_merge", "multirange", &self.multirange, "R",
                &&self.R)
        }
    }
    #[automatically_derived]
    impl<R: ::core::clone::Clone, multirange: ::core::clone::Clone>
        ::core::clone::Clone for multirange_merge<R, multirange> {
        #[inline]
        fn clone(&self) -> multirange_merge<R, multirange> {
            multirange_merge {
                multirange: ::core::clone::Clone::clone(&self.multirange),
                R: ::core::clone::Clone::clone(&self.R),
            }
        }
    }
    #[automatically_derived]
    impl<R: ::core::marker::Copy, multirange: ::core::marker::Copy>
        ::core::marker::Copy for multirange_merge<R, multirange> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R: diesel::query_builder::QueryId,
                multirange: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                multirange_merge<R, multirange> {
                type QueryId =
                    multirange_merge<<R as
                    diesel::query_builder::QueryId>::QueryId,
                    <multirange as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <multirange as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <R as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <multirange as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`multirange_merge()`](fn@multirange_merge)"]
    pub type HelperType<R, multirange> =
        multirange_merge<R, <multirange as AsExpression<R>>::Expression>;
    impl<R: MultirangeOrNullableMultirange + SingleValue, multirange>
        Expression for multirange_merge<R, multirange> where
        (multirange): Expression {
        type SqlType = R::Range;
    }
    impl<R: MultirangeOrNullableMultirange + SingleValue, multirange,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        multirange_merge<R, multirange> where
        multirange: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R: MultirangeOrNullableMultirange + SingleValue, multirange,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        multirange_merge<R, multirange> where
        multirange: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<R: MultirangeOrNullableMultirange + SingleValue, multirange,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        multirange_merge<R, multirange> where
        __DieselInternal: diesel::backend::Backend,
        multirange: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "range_merge";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.multirange.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.multirange.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R: MultirangeOrNullableMultirange + SingleValue, multirange>
        QueryFragment<crate::pg::Pg> for multirange_merge<R, multirange> where
        multirange: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<multirange>(multirange);
    const _: () =
        {
            use diesel;
            impl<multirange, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<multirange> where
                multirange: diesel::expression::ValidGrouping<__GroupByClause>
                {
                type IsAggregate =
                    <multirange as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<R: MultirangeOrNullableMultirange + SingleValue, multirange,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        multirange_merge<R, multirange> where
        __Derived<multirange>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<multirange> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns range of integer"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # table! {"]
#[doc = " #     posts {"]
#[doc = " #         id -> Integer,"]
#[doc = " #         versions -> Int4range,"]
#[doc = " #     }"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use self::posts::dsl::*;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     let conn = &mut establish_connection();"]
#[doc =
" #     diesel::sql_query(\"DROP TABLE IF EXISTS posts\").execute(conn).unwrap();"]
#[doc =
" #     diesel::sql_query(\"CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT4RANGE NOT NULL)\").execute(conn).unwrap();"]
#[doc = " #"]
#[doc = " use diesel::dsl::int4range;"]
#[doc = " use diesel::pg::sql_types::RangeBound;"]
#[doc = ""]
#[doc = " diesel::insert_into(posts)"]
#[doc = "     .values(&["]
#[doc =
"        versions.eq(int4range(Some(3), Some(5), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),"]
#[doc =
"        versions.eq(int4range(None, Some(2), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),"]
#[doc = "     ]).execute(conn)?;"]
#[doc = ""]
#[doc = " let cool_posts = posts.select(versions)"]
#[doc = "     .load::<(Bound<i32>, Bound<i32>)>(conn)?;"]
#[doc = " assert_eq!(vec!["]
#[doc =
"          (Bound::Included(3), Bound::Excluded(6)), // Postgres cast this internally"]
#[doc = "          (Bound::Unbounded, Bound::Excluded(2)),"]
#[doc = "      ], cool_posts);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn int4range<lower, upper,
    bound>(lower: lower, upper: upper, bound: bound)
    -> int4range<lower, upper, bound> where
    lower: diesel::expression::AsExpression<Nullable<Integer>>,
    upper: diesel::expression::AsExpression<Nullable<Integer>>,
    bound: diesel::expression::AsExpression<RangeBoundEnum> {
    int4range_utils::int4range {
        lower: lower.as_expression(),
        upper: upper.as_expression(),
        bound: bound.as_expression(),
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`int4range()`](fn@int4range)"]
pub type int4range<lower, upper, bound> =
    int4range_utils::int4range<<lower as
    diesel::expression::AsExpression<Nullable<Integer>>>::Expression,
    <upper as
    diesel::expression::AsExpression<Nullable<Integer>>>::Expression,
    <bound as diesel::expression::AsExpression<RangeBoundEnum>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod int4range_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct int4range<lower, upper, bound> {
        pub(in super) lower: lower,
        pub(in super) upper: upper,
        pub(in super) bound: bound,
    }
    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<lower, upper, bound, __Rhs> ::std::ops::Add<__Rhs> for
                int4range<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Sub<__Rhs> for
                int4range<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Mul<__Rhs> for
                int4range<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Div<__Rhs> for
                int4range<lower, upper, bound> 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())
                }
            }
        };
    #[automatically_derived]
    impl<lower: ::core::fmt::Debug, upper: ::core::fmt::Debug,
        bound: ::core::fmt::Debug> ::core::fmt::Debug for
        int4range<lower, upper, bound> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f, "int4range",
                "lower", &self.lower, "upper", &self.upper, "bound",
                &&self.bound)
        }
    }
    #[automatically_derived]
    impl<lower: ::core::clone::Clone, upper: ::core::clone::Clone,
        bound: ::core::clone::Clone> ::core::clone::Clone for
        int4range<lower, upper, bound> {
        #[inline]
        fn clone(&self) -> int4range<lower, upper, bound> {
            int4range {
                lower: ::core::clone::Clone::clone(&self.lower),
                upper: ::core::clone::Clone::clone(&self.upper),
                bound: ::core::clone::Clone::clone(&self.bound),
            }
        }
    }
    #[automatically_derived]
    impl<lower: ::core::marker::Copy, upper: ::core::marker::Copy,
        bound: ::core::marker::Copy> ::core::marker::Copy for
        int4range<lower, upper, bound> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<lower: diesel::query_builder::QueryId,
                upper: diesel::query_builder::QueryId,
                bound: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                int4range<lower, upper, bound> {
                type QueryId =
                    int4range<<lower as
                    diesel::query_builder::QueryId>::QueryId,
                    <upper as diesel::query_builder::QueryId>::QueryId,
                    <bound as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <upper as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <bound as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <upper as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <bound as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`int4range()`](fn@int4range)"]
    pub type HelperType<lower, upper, bound> =
        int4range<<lower as AsExpression<Nullable<Integer>>>::Expression,
        <upper as AsExpression<Nullable<Integer>>>::Expression,
        <bound as AsExpression<RangeBoundEnum>>::Expression>;
    impl<lower, upper, bound> Expression for int4range<lower, upper, bound>
        where (lower, upper, bound): Expression {
        type SqlType = Int4range;
    }
    impl<lower, upper, bound, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        int4range<lower, upper, bound> where
        lower: SelectableExpression<__DieselInternal>,
        upper: SelectableExpression<__DieselInternal>,
        bound: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<lower, upper, bound, __DieselInternal>
        AppearsOnTable<__DieselInternal> for int4range<lower, upper, bound>
        where lower: AppearsOnTable<__DieselInternal>,
        upper: AppearsOnTable<__DieselInternal>,
        bound: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<lower, upper, bound, __DieselInternal>
        FunctionFragment<__DieselInternal> for int4range<lower, upper, bound>
        where __DieselInternal: diesel::backend::Backend,
        lower: QueryFragment<__DieselInternal>,
        upper: QueryFragment<__DieselInternal>,
        bound: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "int4range";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.lower.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.lower.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.upper.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.upper.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.bound.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.bound.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<lower, upper, bound> QueryFragment<crate::pg::Pg> for
        int4range<lower, upper, bound> where
        lower: QueryFragment<crate::pg::Pg>,
        upper: QueryFragment<crate::pg::Pg>,
        bound: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<lower, upper, bound>(lower, upper, bound);
    const _: () =
        {
            use diesel;
            impl<lower, upper, bound, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<lower, upper, bound> where
                lower: diesel::expression::ValidGrouping<__GroupByClause>,
                upper: diesel::expression::ValidGrouping<__GroupByClause>,
                bound: diesel::expression::ValidGrouping<__GroupByClause>,
                <lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<upper
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<upper as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<bound
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<lower as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<upper as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<bound as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<lower, upper, bound, __DieselInternal>
        ValidGrouping<__DieselInternal> for int4range<lower, upper, bound>
        where __Derived<lower, upper, bound>: ValidGrouping<__DieselInternal>
        {
        type IsAggregate =
            <__Derived<lower, upper, bound> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns range of big ints"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # table! {"]
#[doc = " #     posts {"]
#[doc = " #         id -> Integer,"]
#[doc = " #         versions -> Int8range,"]
#[doc = " #     }"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use self::posts::dsl::*;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     let conn = &mut establish_connection();"]
#[doc =
" #     diesel::sql_query(\"DROP TABLE IF EXISTS posts\").execute(conn).unwrap();"]
#[doc =
" #     diesel::sql_query(\"CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT8RANGE NOT NULL)\").execute(conn).unwrap();"]
#[doc = " #"]
#[doc = " use diesel::dsl::int8range;"]
#[doc = " use diesel::pg::sql_types::RangeBound;"]
#[doc = ""]
#[doc = " diesel::insert_into(posts)"]
#[doc = "     .values(&["]
#[doc =
"        versions.eq(int8range(Some(3), Some(5), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),"]
#[doc =
"        versions.eq(int8range(None, Some(2), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),"]
#[doc = "     ]).execute(conn)?;"]
#[doc = ""]
#[doc = " let cool_posts = posts.select(versions)"]
#[doc = "     .load::<(Bound<i64>, Bound<i64>)>(conn)?;"]
#[doc = " assert_eq!(vec!["]
#[doc =
"          (Bound::Included(3), Bound::Excluded(6)), // Postgres cast this internally"]
#[doc = "          (Bound::Unbounded, Bound::Excluded(2)),"]
#[doc = "      ], cool_posts);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn int8range<lower, upper,
    bound>(lower: lower, upper: upper, bound: bound)
    -> int8range<lower, upper, bound> where
    lower: diesel::expression::AsExpression<Nullable<BigInt>>,
    upper: diesel::expression::AsExpression<Nullable<BigInt>>,
    bound: diesel::expression::AsExpression<RangeBoundEnum> {
    int8range_utils::int8range {
        lower: lower.as_expression(),
        upper: upper.as_expression(),
        bound: bound.as_expression(),
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`int8range()`](fn@int8range)"]
pub type int8range<lower, upper, bound> =
    int8range_utils::int8range<<lower as
    diesel::expression::AsExpression<Nullable<BigInt>>>::Expression,
    <upper as diesel::expression::AsExpression<Nullable<BigInt>>>::Expression,
    <bound as diesel::expression::AsExpression<RangeBoundEnum>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod int8range_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct int8range<lower, upper, bound> {
        pub(in super) lower: lower,
        pub(in super) upper: upper,
        pub(in super) bound: bound,
    }
    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<lower, upper, bound, __Rhs> ::std::ops::Add<__Rhs> for
                int8range<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Sub<__Rhs> for
                int8range<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Mul<__Rhs> for
                int8range<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Div<__Rhs> for
                int8range<lower, upper, bound> 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())
                }
            }
        };
    #[automatically_derived]
    impl<lower: ::core::fmt::Debug, upper: ::core::fmt::Debug,
        bound: ::core::fmt::Debug> ::core::fmt::Debug for
        int8range<lower, upper, bound> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f, "int8range",
                "lower", &self.lower, "upper", &self.upper, "bound",
                &&self.bound)
        }
    }
    #[automatically_derived]
    impl<lower: ::core::clone::Clone, upper: ::core::clone::Clone,
        bound: ::core::clone::Clone> ::core::clone::Clone for
        int8range<lower, upper, bound> {
        #[inline]
        fn clone(&self) -> int8range<lower, upper, bound> {
            int8range {
                lower: ::core::clone::Clone::clone(&self.lower),
                upper: ::core::clone::Clone::clone(&self.upper),
                bound: ::core::clone::Clone::clone(&self.bound),
            }
        }
    }
    #[automatically_derived]
    impl<lower: ::core::marker::Copy, upper: ::core::marker::Copy,
        bound: ::core::marker::Copy> ::core::marker::Copy for
        int8range<lower, upper, bound> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<lower: diesel::query_builder::QueryId,
                upper: diesel::query_builder::QueryId,
                bound: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                int8range<lower, upper, bound> {
                type QueryId =
                    int8range<<lower as
                    diesel::query_builder::QueryId>::QueryId,
                    <upper as diesel::query_builder::QueryId>::QueryId,
                    <bound as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <upper as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <bound as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <upper as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <bound as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`int8range()`](fn@int8range)"]
    pub type HelperType<lower, upper, bound> =
        int8range<<lower as AsExpression<Nullable<BigInt>>>::Expression,
        <upper as AsExpression<Nullable<BigInt>>>::Expression,
        <bound as AsExpression<RangeBoundEnum>>::Expression>;
    impl<lower, upper, bound> Expression for int8range<lower, upper, bound>
        where (lower, upper, bound): Expression {
        type SqlType = Int8range;
    }
    impl<lower, upper, bound, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        int8range<lower, upper, bound> where
        lower: SelectableExpression<__DieselInternal>,
        upper: SelectableExpression<__DieselInternal>,
        bound: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<lower, upper, bound, __DieselInternal>
        AppearsOnTable<__DieselInternal> for int8range<lower, upper, bound>
        where lower: AppearsOnTable<__DieselInternal>,
        upper: AppearsOnTable<__DieselInternal>,
        bound: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<lower, upper, bound, __DieselInternal>
        FunctionFragment<__DieselInternal> for int8range<lower, upper, bound>
        where __DieselInternal: diesel::backend::Backend,
        lower: QueryFragment<__DieselInternal>,
        upper: QueryFragment<__DieselInternal>,
        bound: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "int8range";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.lower.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.lower.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.upper.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.upper.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.bound.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.bound.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<lower, upper, bound> QueryFragment<crate::pg::Pg> for
        int8range<lower, upper, bound> where
        lower: QueryFragment<crate::pg::Pg>,
        upper: QueryFragment<crate::pg::Pg>,
        bound: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<lower, upper, bound>(lower, upper, bound);
    const _: () =
        {
            use diesel;
            impl<lower, upper, bound, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<lower, upper, bound> where
                lower: diesel::expression::ValidGrouping<__GroupByClause>,
                upper: diesel::expression::ValidGrouping<__GroupByClause>,
                bound: diesel::expression::ValidGrouping<__GroupByClause>,
                <lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<upper
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<upper as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<bound
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<lower as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<upper as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<bound as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<lower, upper, bound, __DieselInternal>
        ValidGrouping<__DieselInternal> for int8range<lower, upper, bound>
        where __Derived<lower, upper, bound>: ValidGrouping<__DieselInternal>
        {
        type IsAggregate =
            <__Derived<lower, upper, bound> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns range of numeric values"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # table! {"]
#[doc = " #     posts {"]
#[doc = " #         id -> Integer,"]
#[doc = " #         versions -> Numrange,"]
#[doc = " #     }"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"numeric\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"numeric\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use self::posts::dsl::*;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     let conn = &mut establish_connection();"]
#[doc =
" #     diesel::sql_query(\"DROP TABLE IF EXISTS posts\").execute(conn).unwrap();"]
#[doc =
" #     diesel::sql_query(\"CREATE TABLE posts (id SERIAL PRIMARY KEY, versions NUMRANGE NOT NULL)\").execute(conn).unwrap();"]
#[doc = " #"]
#[doc = " # use bigdecimal::BigDecimal;"]
#[doc = " use diesel::dsl::numrange;"]
#[doc = " use diesel::pg::sql_types::RangeBound;"]
#[doc = ""]
#[doc = " diesel::insert_into(posts)"]
#[doc = "     .values(&["]
#[doc =
"        versions.eq(numrange(Some(BigDecimal::from(3)), Some(BigDecimal::from(5)), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),"]
#[doc =
"        versions.eq(numrange(None, Some(BigDecimal::from(2)), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),"]
#[doc = "     ]).execute(conn)?;"]
#[doc = ""]
#[doc = " let cool_posts = posts.select(versions)"]
#[doc = "     .load::<(Bound<BigDecimal>, Bound<BigDecimal>)>(conn)?;"]
#[doc = " assert_eq!(vec!["]
#[doc =
"          (Bound::Included(BigDecimal::from(3)), Bound::Included(BigDecimal::from(5))),"]
#[doc = "          (Bound::Unbounded, Bound::Excluded(BigDecimal::from(2))),"]
#[doc = "      ], cool_posts);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn numrange<lower, upper, bound>(lower: lower, upper: upper, bound: bound)
    -> numrange<lower, upper, bound> where
    lower: diesel::expression::AsExpression<Nullable<Numeric>>,
    upper: diesel::expression::AsExpression<Nullable<Numeric>>,
    bound: diesel::expression::AsExpression<RangeBoundEnum> {
    numrange_utils::numrange {
        lower: lower.as_expression(),
        upper: upper.as_expression(),
        bound: bound.as_expression(),
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`numrange()`](fn@numrange)"]
pub type numrange<lower, upper, bound> =
    numrange_utils::numrange<<lower as
    diesel::expression::AsExpression<Nullable<Numeric>>>::Expression,
    <upper as
    diesel::expression::AsExpression<Nullable<Numeric>>>::Expression,
    <bound as diesel::expression::AsExpression<RangeBoundEnum>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod numrange_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct numrange<lower, upper, bound> {
        pub(in super) lower: lower,
        pub(in super) upper: upper,
        pub(in super) bound: bound,
    }
    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<lower, upper, bound, __Rhs> ::std::ops::Add<__Rhs> for
                numrange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Sub<__Rhs> for
                numrange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Mul<__Rhs> for
                numrange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Div<__Rhs> for
                numrange<lower, upper, bound> 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())
                }
            }
        };
    #[automatically_derived]
    impl<lower: ::core::fmt::Debug, upper: ::core::fmt::Debug,
        bound: ::core::fmt::Debug> ::core::fmt::Debug for
        numrange<lower, upper, bound> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f, "numrange",
                "lower", &self.lower, "upper", &self.upper, "bound",
                &&self.bound)
        }
    }
    #[automatically_derived]
    impl<lower: ::core::clone::Clone, upper: ::core::clone::Clone,
        bound: ::core::clone::Clone> ::core::clone::Clone for
        numrange<lower, upper, bound> {
        #[inline]
        fn clone(&self) -> numrange<lower, upper, bound> {
            numrange {
                lower: ::core::clone::Clone::clone(&self.lower),
                upper: ::core::clone::Clone::clone(&self.upper),
                bound: ::core::clone::Clone::clone(&self.bound),
            }
        }
    }
    #[automatically_derived]
    impl<lower: ::core::marker::Copy, upper: ::core::marker::Copy,
        bound: ::core::marker::Copy> ::core::marker::Copy for
        numrange<lower, upper, bound> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<lower: diesel::query_builder::QueryId,
                upper: diesel::query_builder::QueryId,
                bound: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                numrange<lower, upper, bound> {
                type QueryId =
                    numrange<<lower as diesel::query_builder::QueryId>::QueryId,
                    <upper as diesel::query_builder::QueryId>::QueryId,
                    <bound as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <upper as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <bound as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <upper as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <bound as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`numrange()`](fn@numrange)"]
    pub type HelperType<lower, upper, bound> =
        numrange<<lower as AsExpression<Nullable<Numeric>>>::Expression,
        <upper as AsExpression<Nullable<Numeric>>>::Expression,
        <bound as AsExpression<RangeBoundEnum>>::Expression>;
    impl<lower, upper, bound> Expression for numrange<lower, upper, bound>
        where (lower, upper, bound): Expression {
        type SqlType = Numrange;
    }
    impl<lower, upper, bound, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        numrange<lower, upper, bound> where
        lower: SelectableExpression<__DieselInternal>,
        upper: SelectableExpression<__DieselInternal>,
        bound: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<lower, upper, bound, __DieselInternal>
        AppearsOnTable<__DieselInternal> for numrange<lower, upper, bound>
        where lower: AppearsOnTable<__DieselInternal>,
        upper: AppearsOnTable<__DieselInternal>,
        bound: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<lower, upper, bound, __DieselInternal>
        FunctionFragment<__DieselInternal> for numrange<lower, upper, bound>
        where __DieselInternal: diesel::backend::Backend,
        lower: QueryFragment<__DieselInternal>,
        upper: QueryFragment<__DieselInternal>,
        bound: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "numrange";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.lower.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.lower.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.upper.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.upper.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.bound.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.bound.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<lower, upper, bound> QueryFragment<crate::pg::Pg> for
        numrange<lower, upper, bound> where
        lower: QueryFragment<crate::pg::Pg>,
        upper: QueryFragment<crate::pg::Pg>,
        bound: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<lower, upper, bound>(lower, upper, bound);
    const _: () =
        {
            use diesel;
            impl<lower, upper, bound, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<lower, upper, bound> where
                lower: diesel::expression::ValidGrouping<__GroupByClause>,
                upper: diesel::expression::ValidGrouping<__GroupByClause>,
                bound: diesel::expression::ValidGrouping<__GroupByClause>,
                <lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<upper
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<upper as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<bound
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<lower as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<upper as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<bound as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<lower, upper, bound, __DieselInternal>
        ValidGrouping<__DieselInternal> for numrange<lower, upper, bound>
        where __Derived<lower, upper, bound>: ValidGrouping<__DieselInternal>
        {
        type IsAggregate =
            <__Derived<lower, upper, bound> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns range of timestamps without timezone"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # table! {"]
#[doc = " #     posts {"]
#[doc = " #         id -> Integer,"]
#[doc = " #         versions -> Tsrange,"]
#[doc = " #     }"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"time\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"time\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use self::posts::dsl::*;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     let conn = &mut establish_connection();"]
#[doc =
" #     diesel::sql_query(\"DROP TABLE IF EXISTS posts\").execute(conn).unwrap();"]
#[doc =
" #     diesel::sql_query(\"CREATE TABLE posts (id SERIAL PRIMARY KEY, versions TSRANGE NOT NULL)\").execute(conn).unwrap();"]
#[doc = " #"]
#[doc = " use diesel::dsl::tsrange;"]
#[doc = " use diesel::pg::sql_types::RangeBound;"]
#[doc = " use time::{PrimitiveDateTime, macros::datetime};"]
#[doc = ""]
#[doc = " diesel::insert_into(posts)"]
#[doc = "     .values(&["]
#[doc =
"        versions.eq(tsrange(Some(datetime!(2020-01-01 0:00)), Some(datetime!(2021-01-01 0:00)), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),"]
#[doc =
"        versions.eq(tsrange(None, Some(datetime!(2020-01-01 0:00)), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),"]
#[doc = "     ]).execute(conn)?;"]
#[doc = ""]
#[doc = " let cool_posts = posts.select(versions)"]
#[doc =
"     .load::<(Bound<PrimitiveDateTime>, Bound<PrimitiveDateTime>)>(conn)?;"]
#[doc = " assert_eq!(vec!["]
#[doc =
"          (Bound::Included(datetime!(2020-01-01 0:00)), Bound::Included(datetime!(2021-01-01 0:00))),"]
#[doc =
"          (Bound::Unbounded, Bound::Excluded(datetime!(2020-01-01 0:00))),"]
#[doc = "      ], cool_posts);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn tsrange<lower, upper, bound>(lower: lower, upper: upper, bound: bound)
    -> tsrange<lower, upper, bound> where
    lower: diesel::expression::AsExpression<Nullable<Timestamp>>,
    upper: diesel::expression::AsExpression<Nullable<Timestamp>>,
    bound: diesel::expression::AsExpression<RangeBoundEnum> {
    tsrange_utils::tsrange {
        lower: lower.as_expression(),
        upper: upper.as_expression(),
        bound: bound.as_expression(),
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`tsrange()`](fn@tsrange)"]
pub type tsrange<lower, upper, bound> =
    tsrange_utils::tsrange<<lower as
    diesel::expression::AsExpression<Nullable<Timestamp>>>::Expression,
    <upper as
    diesel::expression::AsExpression<Nullable<Timestamp>>>::Expression,
    <bound as diesel::expression::AsExpression<RangeBoundEnum>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod tsrange_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct tsrange<lower, upper, bound> {
        pub(in super) lower: lower,
        pub(in super) upper: upper,
        pub(in super) bound: bound,
    }
    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<lower, upper, bound, __Rhs> ::std::ops::Add<__Rhs> for
                tsrange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Sub<__Rhs> for
                tsrange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Mul<__Rhs> for
                tsrange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Div<__Rhs> for
                tsrange<lower, upper, bound> 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())
                }
            }
        };
    #[automatically_derived]
    impl<lower: ::core::fmt::Debug, upper: ::core::fmt::Debug,
        bound: ::core::fmt::Debug> ::core::fmt::Debug for
        tsrange<lower, upper, bound> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f, "tsrange",
                "lower", &self.lower, "upper", &self.upper, "bound",
                &&self.bound)
        }
    }
    #[automatically_derived]
    impl<lower: ::core::clone::Clone, upper: ::core::clone::Clone,
        bound: ::core::clone::Clone> ::core::clone::Clone for
        tsrange<lower, upper, bound> {
        #[inline]
        fn clone(&self) -> tsrange<lower, upper, bound> {
            tsrange {
                lower: ::core::clone::Clone::clone(&self.lower),
                upper: ::core::clone::Clone::clone(&self.upper),
                bound: ::core::clone::Clone::clone(&self.bound),
            }
        }
    }
    #[automatically_derived]
    impl<lower: ::core::marker::Copy, upper: ::core::marker::Copy,
        bound: ::core::marker::Copy> ::core::marker::Copy for
        tsrange<lower, upper, bound> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<lower: diesel::query_builder::QueryId,
                upper: diesel::query_builder::QueryId,
                bound: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                tsrange<lower, upper, bound> {
                type QueryId =
                    tsrange<<lower as diesel::query_builder::QueryId>::QueryId,
                    <upper as diesel::query_builder::QueryId>::QueryId,
                    <bound as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <upper as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <bound as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <upper as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <bound as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`tsrange()`](fn@tsrange)"]
    pub type HelperType<lower, upper, bound> =
        tsrange<<lower as AsExpression<Nullable<Timestamp>>>::Expression,
        <upper as AsExpression<Nullable<Timestamp>>>::Expression,
        <bound as AsExpression<RangeBoundEnum>>::Expression>;
    impl<lower, upper, bound> Expression for tsrange<lower, upper, bound>
        where (lower, upper, bound): Expression {
        type SqlType = Tsrange;
    }
    impl<lower, upper, bound, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        tsrange<lower, upper, bound> where
        lower: SelectableExpression<__DieselInternal>,
        upper: SelectableExpression<__DieselInternal>,
        bound: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<lower, upper, bound, __DieselInternal>
        AppearsOnTable<__DieselInternal> for tsrange<lower, upper, bound>
        where lower: AppearsOnTable<__DieselInternal>,
        upper: AppearsOnTable<__DieselInternal>,
        bound: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<lower, upper, bound, __DieselInternal>
        FunctionFragment<__DieselInternal> for tsrange<lower, upper, bound>
        where __DieselInternal: diesel::backend::Backend,
        lower: QueryFragment<__DieselInternal>,
        upper: QueryFragment<__DieselInternal>,
        bound: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "tsrange";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.lower.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.lower.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.upper.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.upper.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.bound.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.bound.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<lower, upper, bound> QueryFragment<crate::pg::Pg> for
        tsrange<lower, upper, bound> where
        lower: QueryFragment<crate::pg::Pg>,
        upper: QueryFragment<crate::pg::Pg>,
        bound: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<lower, upper, bound>(lower, upper, bound);
    const _: () =
        {
            use diesel;
            impl<lower, upper, bound, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<lower, upper, bound> where
                lower: diesel::expression::ValidGrouping<__GroupByClause>,
                upper: diesel::expression::ValidGrouping<__GroupByClause>,
                bound: diesel::expression::ValidGrouping<__GroupByClause>,
                <lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<upper
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<upper as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<bound
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<lower as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<upper as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<bound as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<lower, upper, bound, __DieselInternal>
        ValidGrouping<__DieselInternal> for tsrange<lower, upper, bound> where
        __Derived<lower, upper, bound>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<lower, upper, bound> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns range of timestamps with timezone"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # table! {"]
#[doc = " #     posts {"]
#[doc = " #         id -> Integer,"]
#[doc = " #         versions -> Tstzrange,"]
#[doc = " #     }"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"time\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"time\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use self::posts::dsl::*;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     let conn = &mut establish_connection();"]
#[doc =
" #     diesel::sql_query(\"DROP TABLE IF EXISTS posts\").execute(conn).unwrap();"]
#[doc =
" #     diesel::sql_query(\"CREATE TABLE posts (id SERIAL PRIMARY KEY, versions TSTZRANGE NOT NULL)\").execute(conn).unwrap();"]
#[doc = " #"]
#[doc = " use diesel::dsl::tstzrange;"]
#[doc = " use diesel::pg::sql_types::RangeBound;"]
#[doc = " use time::{OffsetDateTime, macros::datetime};"]
#[doc = ""]
#[doc = " diesel::insert_into(posts)"]
#[doc = "     .values(&["]
#[doc =
"        versions.eq(tstzrange(Some(datetime!(2020-01-01 0:00 UTC)), Some(datetime!(2021-01-01 0:00 -3)), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),"]
#[doc =
"        versions.eq(tstzrange(None, Some(datetime!(2020-01-01 0:00 +2)), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),"]
#[doc = "     ]).execute(conn)?;"]
#[doc = ""]
#[doc = " let cool_posts = posts.select(versions)"]
#[doc =
"     .load::<(Bound<OffsetDateTime>, Bound<OffsetDateTime>)>(conn)?;"]
#[doc = " assert_eq!(vec!["]
#[doc =
"          (Bound::Included(datetime!(2020-01-01 0:00 UTC)), Bound::Included(datetime!(2021-01-01 0:00 -3))),"]
#[doc =
"          (Bound::Unbounded, Bound::Excluded(datetime!(2020-01-01 0:00 +2))),"]
#[doc = "      ], cool_posts);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn tstzrange<lower, upper,
    bound>(lower: lower, upper: upper, bound: bound)
    -> tstzrange<lower, upper, bound> where
    lower: diesel::expression::AsExpression<Nullable<Timestamptz>>,
    upper: diesel::expression::AsExpression<Nullable<Timestamptz>>,
    bound: diesel::expression::AsExpression<RangeBoundEnum> {
    tstzrange_utils::tstzrange {
        lower: lower.as_expression(),
        upper: upper.as_expression(),
        bound: bound.as_expression(),
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`tstzrange()`](fn@tstzrange)"]
pub type tstzrange<lower, upper, bound> =
    tstzrange_utils::tstzrange<<lower as
    diesel::expression::AsExpression<Nullable<Timestamptz>>>::Expression,
    <upper as
    diesel::expression::AsExpression<Nullable<Timestamptz>>>::Expression,
    <bound as diesel::expression::AsExpression<RangeBoundEnum>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod tstzrange_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct tstzrange<lower, upper, bound> {
        pub(in super) lower: lower,
        pub(in super) upper: upper,
        pub(in super) bound: bound,
    }
    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<lower, upper, bound, __Rhs> ::std::ops::Add<__Rhs> for
                tstzrange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Sub<__Rhs> for
                tstzrange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Mul<__Rhs> for
                tstzrange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Div<__Rhs> for
                tstzrange<lower, upper, bound> 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())
                }
            }
        };
    #[automatically_derived]
    impl<lower: ::core::fmt::Debug, upper: ::core::fmt::Debug,
        bound: ::core::fmt::Debug> ::core::fmt::Debug for
        tstzrange<lower, upper, bound> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f, "tstzrange",
                "lower", &self.lower, "upper", &self.upper, "bound",
                &&self.bound)
        }
    }
    #[automatically_derived]
    impl<lower: ::core::clone::Clone, upper: ::core::clone::Clone,
        bound: ::core::clone::Clone> ::core::clone::Clone for
        tstzrange<lower, upper, bound> {
        #[inline]
        fn clone(&self) -> tstzrange<lower, upper, bound> {
            tstzrange {
                lower: ::core::clone::Clone::clone(&self.lower),
                upper: ::core::clone::Clone::clone(&self.upper),
                bound: ::core::clone::Clone::clone(&self.bound),
            }
        }
    }
    #[automatically_derived]
    impl<lower: ::core::marker::Copy, upper: ::core::marker::Copy,
        bound: ::core::marker::Copy> ::core::marker::Copy for
        tstzrange<lower, upper, bound> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<lower: diesel::query_builder::QueryId,
                upper: diesel::query_builder::QueryId,
                bound: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                tstzrange<lower, upper, bound> {
                type QueryId =
                    tstzrange<<lower as
                    diesel::query_builder::QueryId>::QueryId,
                    <upper as diesel::query_builder::QueryId>::QueryId,
                    <bound as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <upper as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <bound as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <upper as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <bound as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`tstzrange()`](fn@tstzrange)"]
    pub type HelperType<lower, upper, bound> =
        tstzrange<<lower as AsExpression<Nullable<Timestamptz>>>::Expression,
        <upper as AsExpression<Nullable<Timestamptz>>>::Expression,
        <bound as AsExpression<RangeBoundEnum>>::Expression>;
    impl<lower, upper, bound> Expression for tstzrange<lower, upper, bound>
        where (lower, upper, bound): Expression {
        type SqlType = Tstzrange;
    }
    impl<lower, upper, bound, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        tstzrange<lower, upper, bound> where
        lower: SelectableExpression<__DieselInternal>,
        upper: SelectableExpression<__DieselInternal>,
        bound: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<lower, upper, bound, __DieselInternal>
        AppearsOnTable<__DieselInternal> for tstzrange<lower, upper, bound>
        where lower: AppearsOnTable<__DieselInternal>,
        upper: AppearsOnTable<__DieselInternal>,
        bound: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<lower, upper, bound, __DieselInternal>
        FunctionFragment<__DieselInternal> for tstzrange<lower, upper, bound>
        where __DieselInternal: diesel::backend::Backend,
        lower: QueryFragment<__DieselInternal>,
        upper: QueryFragment<__DieselInternal>,
        bound: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "tstzrange";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.lower.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.lower.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.upper.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.upper.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.bound.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.bound.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<lower, upper, bound> QueryFragment<crate::pg::Pg> for
        tstzrange<lower, upper, bound> where
        lower: QueryFragment<crate::pg::Pg>,
        upper: QueryFragment<crate::pg::Pg>,
        bound: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<lower, upper, bound>(lower, upper, bound);
    const _: () =
        {
            use diesel;
            impl<lower, upper, bound, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<lower, upper, bound> where
                lower: diesel::expression::ValidGrouping<__GroupByClause>,
                upper: diesel::expression::ValidGrouping<__GroupByClause>,
                bound: diesel::expression::ValidGrouping<__GroupByClause>,
                <lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<upper
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<upper as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<bound
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<lower as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<upper as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<bound as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<lower, upper, bound, __DieselInternal>
        ValidGrouping<__DieselInternal> for tstzrange<lower, upper, bound>
        where __Derived<lower, upper, bound>: ValidGrouping<__DieselInternal>
        {
        type IsAggregate =
            <__Derived<lower, upper, bound> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns range of dates"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # table! {"]
#[doc = " #     posts {"]
#[doc = " #         id -> Integer,"]
#[doc = " #         versions -> Daterange,"]
#[doc = " #     }"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"time\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"time\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use self::posts::dsl::*;"]
#[doc = " #     use std::collections::Bound;"]
#[doc = " #     let conn = &mut establish_connection();"]
#[doc =
" #     diesel::sql_query(\"DROP TABLE IF EXISTS posts\").execute(conn).unwrap();"]
#[doc =
" #     diesel::sql_query(\"CREATE TABLE posts (id SERIAL PRIMARY KEY, versions DATERANGE NOT NULL)\").execute(conn).unwrap();"]
#[doc = " #"]
#[doc = " use diesel::dsl::daterange;"]
#[doc = " use diesel::pg::sql_types::RangeBound;"]
#[doc = " use time::{Date, macros::date};"]
#[doc = ""]
#[doc = " diesel::insert_into(posts)"]
#[doc = "     .values(&["]
#[doc =
"        versions.eq(daterange(Some(date!(2020-01-01)), Some(date!(2021-01-01)), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),"]
#[doc =
"        versions.eq(daterange(None, Some(date!(2020-01-01)), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),"]
#[doc = "     ]).execute(conn)?;"]
#[doc = ""]
#[doc = " let cool_posts = posts.select(versions)"]
#[doc = "     .load::<(Bound<Date>, Bound<Date>)>(conn)?;"]
#[doc = " assert_eq!(vec!["]
#[doc =
"          (Bound::Included(date!(2020-01-01)), Bound::Excluded(date!(2021-01-02))),"]
#[doc = "          (Bound::Unbounded, Bound::Excluded(date!(2020-01-01))),"]
#[doc = "      ], cool_posts);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn daterange<lower, upper,
    bound>(lower: lower, upper: upper, bound: bound)
    -> daterange<lower, upper, bound> where
    lower: diesel::expression::AsExpression<Nullable<Date>>,
    upper: diesel::expression::AsExpression<Nullable<Date>>,
    bound: diesel::expression::AsExpression<RangeBoundEnum> {
    daterange_utils::daterange {
        lower: lower.as_expression(),
        upper: upper.as_expression(),
        bound: bound.as_expression(),
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`daterange()`](fn@daterange)"]
pub type daterange<lower, upper, bound> =
    daterange_utils::daterange<<lower as
    diesel::expression::AsExpression<Nullable<Date>>>::Expression,
    <upper as diesel::expression::AsExpression<Nullable<Date>>>::Expression,
    <bound as diesel::expression::AsExpression<RangeBoundEnum>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod daterange_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct daterange<lower, upper, bound> {
        pub(in super) lower: lower,
        pub(in super) upper: upper,
        pub(in super) bound: bound,
    }
    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<lower, upper, bound, __Rhs> ::std::ops::Add<__Rhs> for
                daterange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Sub<__Rhs> for
                daterange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Mul<__Rhs> for
                daterange<lower, upper, bound> 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<lower, upper, bound, __Rhs> ::std::ops::Div<__Rhs> for
                daterange<lower, upper, bound> 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())
                }
            }
        };
    #[automatically_derived]
    impl<lower: ::core::fmt::Debug, upper: ::core::fmt::Debug,
        bound: ::core::fmt::Debug> ::core::fmt::Debug for
        daterange<lower, upper, bound> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f, "daterange",
                "lower", &self.lower, "upper", &self.upper, "bound",
                &&self.bound)
        }
    }
    #[automatically_derived]
    impl<lower: ::core::clone::Clone, upper: ::core::clone::Clone,
        bound: ::core::clone::Clone> ::core::clone::Clone for
        daterange<lower, upper, bound> {
        #[inline]
        fn clone(&self) -> daterange<lower, upper, bound> {
            daterange {
                lower: ::core::clone::Clone::clone(&self.lower),
                upper: ::core::clone::Clone::clone(&self.upper),
                bound: ::core::clone::Clone::clone(&self.bound),
            }
        }
    }
    #[automatically_derived]
    impl<lower: ::core::marker::Copy, upper: ::core::marker::Copy,
        bound: ::core::marker::Copy> ::core::marker::Copy for
        daterange<lower, upper, bound> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<lower: diesel::query_builder::QueryId,
                upper: diesel::query_builder::QueryId,
                bound: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                daterange<lower, upper, bound> {
                type QueryId =
                    daterange<<lower as
                    diesel::query_builder::QueryId>::QueryId,
                    <upper as diesel::query_builder::QueryId>::QueryId,
                    <bound as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <upper as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <bound as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <lower as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <upper as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <bound as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`daterange()`](fn@daterange)"]
    pub type HelperType<lower, upper, bound> =
        daterange<<lower as AsExpression<Nullable<Date>>>::Expression,
        <upper as AsExpression<Nullable<Date>>>::Expression,
        <bound as AsExpression<RangeBoundEnum>>::Expression>;
    impl<lower, upper, bound> Expression for daterange<lower, upper, bound>
        where (lower, upper, bound): Expression {
        type SqlType = Daterange;
    }
    impl<lower, upper, bound, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        daterange<lower, upper, bound> where
        lower: SelectableExpression<__DieselInternal>,
        upper: SelectableExpression<__DieselInternal>,
        bound: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<lower, upper, bound, __DieselInternal>
        AppearsOnTable<__DieselInternal> for daterange<lower, upper, bound>
        where lower: AppearsOnTable<__DieselInternal>,
        upper: AppearsOnTable<__DieselInternal>,
        bound: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<lower, upper, bound, __DieselInternal>
        FunctionFragment<__DieselInternal> for daterange<lower, upper, bound>
        where __DieselInternal: diesel::backend::Backend,
        lower: QueryFragment<__DieselInternal>,
        upper: QueryFragment<__DieselInternal>,
        bound: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "daterange";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.lower.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.lower.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.upper.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.upper.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.bound.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.bound.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<lower, upper, bound> QueryFragment<crate::pg::Pg> for
        daterange<lower, upper, bound> where
        lower: QueryFragment<crate::pg::Pg>,
        upper: QueryFragment<crate::pg::Pg>,
        bound: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<lower, upper, bound>(lower, upper, bound);
    const _: () =
        {
            use diesel;
            impl<lower, upper, bound, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<lower, upper, bound> where
                lower: diesel::expression::ValidGrouping<__GroupByClause>,
                upper: diesel::expression::ValidGrouping<__GroupByClause>,
                bound: diesel::expression::ValidGrouping<__GroupByClause>,
                <lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<upper
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<lower as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<upper as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<bound
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<lower as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<upper as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<bound as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<lower, upper, bound, __DieselInternal>
        ValidGrouping<__DieselInternal> for daterange<lower, upper, bound>
        where __Derived<lower, upper, bound>: ValidGrouping<__DieselInternal>
        {
        type IsAggregate =
            <__Derived<lower, upper, bound> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Append an element to the end of an array"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_append;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let ints = diesel::select(array_append::<Array<_>, Integer, _, _>(vec![1, 2], 3))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![1, 2, 3], ints);"]
#[doc = ""]
#[doc =
" let ints = diesel::select(array_append::<Array<_>, Nullable<Integer>, _, _>("]
#[doc = "     vec![Some(1), Some(2)],"]
#[doc = "     None::<i32>,"]
#[doc = " ))"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![Some(1), Some(2), None], ints);"]
#[doc = ""]
#[doc =
" let ints = diesel::select(array_append::<Nullable<Array<_>>, Integer, _, _>("]
#[doc = "     None::<Vec<i32>>,"]
#[doc = "     3,"]
#[doc = " ))"]
#[doc = " .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![3], ints);"]
#[doc = ""]
#[doc =
" let ints = diesel::select(array_append::<Nullable<Array<_>>, Nullable<Integer>, _, _>("]
#[doc = "     None::<Vec<i32>>,"]
#[doc = "     None::<i32>,"]
#[doc = " ))"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![None], ints);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_append<Arr: ArrayOrNullableArray<Inner = T> + SingleValue,
    T: SingleValue, a, e>(a: a, e: e) -> array_append<Arr, T, a, e> where
    a: diesel::expression::AsExpression<Arr>,
    e: diesel::expression::AsExpression<T> {
    array_append_utils::array_append {
        a: a.as_expression(),
        e: e.as_expression(),
        Arr: ::std::marker::PhantomData,
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_append()`](fn@array_append)"]
pub type array_append<Arr, T, a, e> =
    array_append_utils::array_append<Arr, T,
    <a as diesel::expression::AsExpression<Arr>>::Expression,
    <e as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_append_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_append<Arr, T, a, e> {
        pub(in super) a: a,
        pub(in super) e: e,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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<Arr, T, a, e, __Rhs> ::std::ops::Add<__Rhs> for
                array_append<Arr, T, a, e> 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<Arr, T, a, e, __Rhs> ::std::ops::Sub<__Rhs> for
                array_append<Arr, T, a, e> 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<Arr, T, a, e, __Rhs> ::std::ops::Mul<__Rhs> for
                array_append<Arr, T, a, e> 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<Arr, T, a, e, __Rhs> ::std::ops::Div<__Rhs> for
                array_append<Arr, T, a, e> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, T: ::core::fmt::Debug,
        a: ::core::fmt::Debug, e: ::core::fmt::Debug> ::core::fmt::Debug for
        array_append<Arr, T, a, e> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "array_append", "a", &self.a, "e", &self.e, "Arr", &self.Arr,
                "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, T: ::core::clone::Clone,
        a: ::core::clone::Clone, e: ::core::clone::Clone> ::core::clone::Clone
        for array_append<Arr, T, a, e> {
        #[inline]
        fn clone(&self) -> array_append<Arr, T, a, e> {
            array_append {
                a: ::core::clone::Clone::clone(&self.a),
                e: ::core::clone::Clone::clone(&self.e),
                Arr: ::core::clone::Clone::clone(&self.Arr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, T: ::core::marker::Copy,
        a: ::core::marker::Copy, e: ::core::marker::Copy> ::core::marker::Copy
        for array_append<Arr, T, a, e> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                T: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                e: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_append<Arr, T, a, e>
                {
                type QueryId =
                    array_append<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <T as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <e as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <e as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    || <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            || <e as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_append()`](fn@array_append)"]
    pub type HelperType<Arr, T, a, e> =
        array_append<Arr, T, <a as AsExpression<Arr>>::Expression,
        <e as AsExpression<T>>::Expression>;
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e> Expression for array_append<Arr, T, a, e> where
        (a, e): Expression {
        type SqlType = Array<T>;
    }
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, __DieselInternal> SelectableExpression<__DieselInternal> for
        array_append<Arr, T, a, e> where
        a: SelectableExpression<__DieselInternal>,
        e: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_append<Arr, T, a, e> where a: AppearsOnTable<__DieselInternal>,
        e: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, __DieselInternal> FunctionFragment<__DieselInternal> for
        array_append<Arr, T, a, e> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>, e: QueryFragment<__DieselInternal>
        {
        const FUNCTION_NAME: &'static str = "array_append";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.e.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.e.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e> QueryFragment<crate::pg::Pg> for array_append<Arr, T, a, e>
        where a: QueryFragment<crate::pg::Pg>, e: QueryFragment<crate::pg::Pg>
        {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, e>(a, e);
    const _: () =
        {
            use diesel;
            impl<a, e, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, e> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                e: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<e
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<e as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, __DieselInternal> ValidGrouping<__DieselInternal> for
        array_append<Arr, T, a, e> where
        __Derived<a, e>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, e> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Replace all occurrences of an element in an array with a given element"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_replace;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let ints = diesel::select(array_replace::<Array<_>, Integer, _, _, _>("]
#[doc = "     vec![1, 2, 5, 4],"]
#[doc = "     5,"]
#[doc = "     3,"]
#[doc = " ))"]
#[doc = " .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![1, 2, 3, 4], ints);"]
#[doc = ""]
#[doc =
" let ints = diesel::select(array_replace::<Array<_>, Nullable<Integer>, _, _, _>("]
#[doc = "     vec![Some(1), Some(2), Some(3)],"]
#[doc = "     Some(3),"]
#[doc = "     None::<i32>,"]
#[doc = " ))"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![Some(1), Some(2), None], ints);"]
#[doc = ""]
#[doc =
" let ints = diesel::select(array_replace::<Nullable<Array<_>>, Integer, _, _, _>("]
#[doc = "     None::<Vec<i32>>,"]
#[doc = "     1,"]
#[doc = "     2,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<Vec<i32>>>(connection)?;"]
#[doc = ""]
#[doc = " let ints = diesel::select(array_replace::<"]
#[doc = "     Nullable<Array<_>>,"]
#[doc = "     Nullable<Integer>,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = " >(None::<Vec<i32>>, None::<i32>, Some(1)))"]
#[doc = " .get_result::<Option<Vec<Option<i32>>>>(connection)?;"]
#[doc = " assert_eq!(None, ints);"]
#[doc = " #    Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_replace<Arr: ArrayOrNullableArray<Inner = T> + SingleValue,
    T: SingleValue, a, e, r>(a: a, e: e, r: r)
    -> array_replace<Arr, T, a, e, r> where
    a: diesel::expression::AsExpression<Arr>,
    e: diesel::expression::AsExpression<T>,
    r: diesel::expression::AsExpression<T> {
    array_replace_utils::array_replace {
        a: a.as_expression(),
        e: e.as_expression(),
        r: r.as_expression(),
        Arr: ::std::marker::PhantomData,
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_replace()`](fn@array_replace)"]
pub type array_replace<Arr, T, a, e, r> =
    array_replace_utils::array_replace<Arr, T,
    <a as diesel::expression::AsExpression<Arr>>::Expression,
    <e as diesel::expression::AsExpression<T>>::Expression,
    <r as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_replace_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_replace<Arr, T, a, e, r> {
        pub(in super) a: a,
        pub(in super) e: e,
        pub(in super) r: r,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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<Arr, T, a, e, r, __Rhs> ::std::ops::Add<__Rhs> for
                array_replace<Arr, T, a, e, r> 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<Arr, T, a, e, r, __Rhs> ::std::ops::Sub<__Rhs> for
                array_replace<Arr, T, a, e, r> 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<Arr, T, a, e, r, __Rhs> ::std::ops::Mul<__Rhs> for
                array_replace<Arr, T, a, e, r> 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<Arr, T, a, e, r, __Rhs> ::std::ops::Div<__Rhs> for
                array_replace<Arr, T, a, e, r> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, T: ::core::fmt::Debug,
        a: ::core::fmt::Debug, e: ::core::fmt::Debug, r: ::core::fmt::Debug>
        ::core::fmt::Debug for array_replace<Arr, T, a, e, r> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field5_finish(f,
                "array_replace", "a", &self.a, "e", &self.e, "r", &self.r,
                "Arr", &self.Arr, "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, T: ::core::clone::Clone,
        a: ::core::clone::Clone, e: ::core::clone::Clone,
        r: ::core::clone::Clone> ::core::clone::Clone for
        array_replace<Arr, T, a, e, r> {
        #[inline]
        fn clone(&self) -> array_replace<Arr, T, a, e, r> {
            array_replace {
                a: ::core::clone::Clone::clone(&self.a),
                e: ::core::clone::Clone::clone(&self.e),
                r: ::core::clone::Clone::clone(&self.r),
                Arr: ::core::clone::Clone::clone(&self.Arr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, T: ::core::marker::Copy,
        a: ::core::marker::Copy, e: ::core::marker::Copy,
        r: ::core::marker::Copy> ::core::marker::Copy for
        array_replace<Arr, T, a, e, r> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                T: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                e: diesel::query_builder::QueryId,
                r: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_replace<Arr, T, a, e, r> {
                type QueryId =
                    array_replace<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <T as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <e as diesel::query_builder::QueryId>::QueryId,
                    <r as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                        &&
                                        <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <e as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <r as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                        || <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                || <e as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            || <r as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_replace()`](fn@array_replace)"]
    pub type HelperType<Arr, T, a, e, r> =
        array_replace<Arr, T, <a as AsExpression<Arr>>::Expression,
        <e as AsExpression<T>>::Expression,
        <r as AsExpression<T>>::Expression>;
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, r> Expression for array_replace<Arr, T, a, e, r> where
        (a, e, r): Expression {
        type SqlType = Arr;
    }
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, r, __DieselInternal> SelectableExpression<__DieselInternal> for
        array_replace<Arr, T, a, e, r> where
        a: SelectableExpression<__DieselInternal>,
        e: SelectableExpression<__DieselInternal>,
        r: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, r, __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_replace<Arr, T, a, e, r> where
        a: AppearsOnTable<__DieselInternal>,
        e: AppearsOnTable<__DieselInternal>,
        r: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, r, __DieselInternal> FunctionFragment<__DieselInternal> for
        array_replace<Arr, T, a, e, r> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>,
        e: QueryFragment<__DieselInternal>, r: QueryFragment<__DieselInternal>
        {
        const FUNCTION_NAME: &'static str = "array_replace";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.e.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.e.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.r.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.r.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, r> QueryFragment<crate::pg::Pg> for
        array_replace<Arr, T, a, e, r> where a: QueryFragment<crate::pg::Pg>,
        e: QueryFragment<crate::pg::Pg>, r: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, e, r>(a, e, r);
    const _: () =
        {
            use diesel;
            impl<a, e, r, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, e, r> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                e: diesel::expression::ValidGrouping<__GroupByClause>,
                r: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<e
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<e as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<r
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<e as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<r as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, r, __DieselInternal> ValidGrouping<__DieselInternal> for
        array_replace<Arr, T, a, e, r> where
        __Derived<a, e, r>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, e, r> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns a text representation of the array\'s dimensions"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main(){"]
#[doc = " #    run_test().unwrap();"]
#[doc = " # }"]
#[doc = " # fn run_test()->QueryResult<()>{"]
#[doc = " #   use diesel::dsl::array_dims;"]
#[doc = " #   use diesel::sql_types::{Nullable,Array,Integer};"]
#[doc = " #   let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let dims = diesel::select(array_dims::<Array<Integer>,_>(vec![1,2]))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = " assert!(String::from(\"[1:2]\").eq(&dims));"]
#[doc = ""]
#[doc =
" let dims = diesel::select(array_dims::<Array<Nullable<Integer>>,_>(vec![None::<i32>,Some(2)]))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = " assert!(String::from(\"[1:2]\").eq(&dims));"]
#[doc = ""]
#[doc =
" let dims = diesel::select(array_dims::<Array<Nullable<Integer>>,_>(vec![None::<i32>]))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = " assert!(String::from(\"[1:1]\").eq(&dims));"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[allow(non_camel_case_types)]
pub fn array_dims<Arr: ArrayOrNullableArray + SingleValue, arr>(arr: arr)
    -> array_dims<Arr, arr> where arr: diesel::expression::AsExpression<Arr> {
    array_dims_utils::array_dims {
        arr: arr.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_dims()`](fn@array_dims)"]
pub type array_dims<Arr, arr> =
    array_dims_utils::array_dims<Arr,
    <arr as diesel::expression::AsExpression<Arr>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_dims_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_dims<Arr, arr> {
        pub(in super) arr: arr,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, arr, __Rhs> ::std::ops::Add<__Rhs> for
                array_dims<Arr, arr> 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<Arr, arr, __Rhs> ::std::ops::Sub<__Rhs> for
                array_dims<Arr, arr> 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<Arr, arr, __Rhs> ::std::ops::Mul<__Rhs> for
                array_dims<Arr, arr> 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<Arr, arr, __Rhs> ::std::ops::Div<__Rhs> for
                array_dims<Arr, arr> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, arr: ::core::fmt::Debug> ::core::fmt::Debug
        for array_dims<Arr, arr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "array_dims", "arr", &self.arr, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, arr: ::core::clone::Clone>
        ::core::clone::Clone for array_dims<Arr, arr> {
        #[inline]
        fn clone(&self) -> array_dims<Arr, arr> {
            array_dims {
                arr: ::core::clone::Clone::clone(&self.arr),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, arr: ::core::marker::Copy>
        ::core::marker::Copy for array_dims<Arr, arr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                arr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_dims<Arr, arr> {
                type QueryId =
                    array_dims<<Arr as diesel::query_builder::QueryId>::QueryId,
                    <arr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_dims()`](fn@array_dims)"]
    pub type HelperType<Arr, arr> =
        array_dims<Arr, <arr as AsExpression<Arr>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, arr> Expression for
        array_dims<Arr, arr> where (arr): Expression {
        type SqlType = Text;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, arr, __DieselInternal>
        SelectableExpression<__DieselInternal> for array_dims<Arr, arr> where
        arr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, arr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for array_dims<Arr, arr> where
        arr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, arr, __DieselInternal>
        FunctionFragment<__DieselInternal> for array_dims<Arr, arr> where
        __DieselInternal: diesel::backend::Backend,
        arr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_dims";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.arr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.arr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, arr>
        QueryFragment<crate::pg::Pg> for array_dims<Arr, arr> where
        arr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<arr>(arr);
    const _: () =
        {
            use diesel;
            impl<arr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<arr> where
                arr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <arr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, arr, __DieselInternal>
        ValidGrouping<__DieselInternal> for array_dims<Arr, arr> where
        __Derived<arr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<arr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Prepends an element to the beginning of an array"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_prepend;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let ints = diesel::select(array_prepend::<Integer, Array<_>, _, _>(3, vec![1, 2]))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![3, 1, 2], ints);"]
#[doc = ""]
#[doc =
" let ints = diesel::select(array_prepend::<Nullable<Integer>, Array<_>, _, _>("]
#[doc = "     None::<i32>,"]
#[doc = "     vec![Some(1), Some(2)],"]
#[doc = " ))"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![None, Some(1), Some(2)], ints);"]
#[doc = ""]
#[doc =
" let ints = diesel::select(array_prepend::<Integer, Nullable<Array<_>>, _, _>("]
#[doc = "     3,"]
#[doc = "     None::<Vec<i32>>,"]
#[doc = " ))"]
#[doc = " .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![3], ints);"]
#[doc = ""]
#[doc = " let ints = diesel::select("]
#[doc =
"     array_prepend::<Nullable<Integer>, Nullable<Array<_>>, _, _>(None::<i32>, None::<Vec<i32>>),"]
#[doc = " )"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![None], ints);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_prepend<T: SingleValue, Arr: ArrayOrNullableArray<Inner = T> +
    SingleValue, e, a>(e: e, a: a) -> array_prepend<T, Arr, e, a> where
    e: diesel::expression::AsExpression<T>,
    a: diesel::expression::AsExpression<Arr> {
    array_prepend_utils::array_prepend {
        e: e.as_expression(),
        a: a.as_expression(),
        T: ::std::marker::PhantomData,
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_prepend()`](fn@array_prepend)"]
pub type array_prepend<T, Arr, e, a> =
    array_prepend_utils::array_prepend<T, Arr,
    <e as diesel::expression::AsExpression<T>>::Expression,
    <a as diesel::expression::AsExpression<Arr>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_prepend_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_prepend<T, Arr, e, a> {
        pub(in super) e: e,
        pub(in super) a: a,
        pub(in super) T: ::std::marker::PhantomData<T>,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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, Arr, e, a, __Rhs> ::std::ops::Add<__Rhs> for
                array_prepend<T, Arr, e, a> 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, Arr, e, a, __Rhs> ::std::ops::Sub<__Rhs> for
                array_prepend<T, Arr, e, a> 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, Arr, e, a, __Rhs> ::std::ops::Mul<__Rhs> for
                array_prepend<T, Arr, e, a> 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, Arr, e, a, __Rhs> ::std::ops::Div<__Rhs> for
                array_prepend<T, Arr, e, a> 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())
                }
            }
        };
    #[automatically_derived]
    impl<T: ::core::fmt::Debug, Arr: ::core::fmt::Debug,
        e: ::core::fmt::Debug, a: ::core::fmt::Debug> ::core::fmt::Debug for
        array_prepend<T, Arr, e, a> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "array_prepend", "e", &self.e, "a", &self.a, "T", &self.T,
                "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<T: ::core::clone::Clone, Arr: ::core::clone::Clone,
        e: ::core::clone::Clone, a: ::core::clone::Clone> ::core::clone::Clone
        for array_prepend<T, Arr, e, a> {
        #[inline]
        fn clone(&self) -> array_prepend<T, Arr, e, a> {
            array_prepend {
                e: ::core::clone::Clone::clone(&self.e),
                a: ::core::clone::Clone::clone(&self.a),
                T: ::core::clone::Clone::clone(&self.T),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<T: ::core::marker::Copy, Arr: ::core::marker::Copy,
        e: ::core::marker::Copy, a: ::core::marker::Copy> ::core::marker::Copy
        for array_prepend<T, Arr, e, a> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<T: diesel::query_builder::QueryId,
                Arr: diesel::query_builder::QueryId,
                e: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_prepend<T, Arr, e, a>
                {
                type QueryId =
                    array_prepend<<T as
                    diesel::query_builder::QueryId>::QueryId,
                    <Arr as diesel::query_builder::QueryId>::QueryId,
                    <e as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <e as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                || <e as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_prepend()`](fn@array_prepend)"]
    pub type HelperType<T, Arr, e, a> =
        array_prepend<T, Arr, <e as AsExpression<T>>::Expression,
        <a as AsExpression<Arr>>::Expression>;
    impl<T: SingleValue, Arr: ArrayOrNullableArray<Inner = T> + SingleValue,
        e, a> Expression for array_prepend<T, Arr, e, a> where
        (e, a): Expression {
        type SqlType = Array<T>;
    }
    impl<T: SingleValue, Arr: ArrayOrNullableArray<Inner = T> + SingleValue,
        e, a, __DieselInternal> SelectableExpression<__DieselInternal> for
        array_prepend<T, Arr, e, a> where
        e: SelectableExpression<__DieselInternal>,
        a: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<T: SingleValue, Arr: ArrayOrNullableArray<Inner = T> + SingleValue,
        e, a, __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_prepend<T, Arr, e, a> where e: AppearsOnTable<__DieselInternal>,
        a: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<T: SingleValue, Arr: ArrayOrNullableArray<Inner = T> + SingleValue,
        e, a, __DieselInternal> FunctionFragment<__DieselInternal> for
        array_prepend<T, Arr, e, a> where
        __DieselInternal: diesel::backend::Backend,
        e: QueryFragment<__DieselInternal>, a: QueryFragment<__DieselInternal>
        {
        const FUNCTION_NAME: &'static str = "array_prepend";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.e.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.e.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<T: SingleValue, Arr: ArrayOrNullableArray<Inner = T> + SingleValue,
        e, a> QueryFragment<crate::pg::Pg> for array_prepend<T, Arr, e, a>
        where e: QueryFragment<crate::pg::Pg>, a: QueryFragment<crate::pg::Pg>
        {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<e, a>(e, a);
    const _: () =
        {
            use diesel;
            impl<e, a, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<e, a> where
                e: diesel::expression::ValidGrouping<__GroupByClause>,
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                <e as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<a
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<e as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<T: SingleValue, Arr: ArrayOrNullableArray<Inner = T> + SingleValue,
        e, a, __DieselInternal> ValidGrouping<__DieselInternal> for
        array_prepend<T, Arr, e, a> where
        __Derived<e, a>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<e, a> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Removes all elements equal to the given value from the array"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_remove;"]
#[doc = " #     use diesel::sql_types::{Nullable, Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let ints = diesel::select(array_remove::<Array<_>, Integer, _, _>(vec![1, 2, 3, 2], 2))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![1, 3], ints);"]
#[doc = ""]
#[doc =
" let ints = diesel::select(array_remove::<Array<_>, Nullable<Integer>, _, _>("]
#[doc = "     vec![None, Some(1), Some(2), None, Some(4)],"]
#[doc = "     None::<i32>,"]
#[doc = " ))"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![Some(1), Some(2), Some(4)], ints);"]
#[doc = ""]
#[doc =
" let ints = diesel::select(array_remove::<Nullable<Array<_>>, Nullable<Integer>, _, _>("]
#[doc = "     None::<Vec<i32>>,"]
#[doc = "     None::<i32>,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<Vec<Option<i32>>>>(connection)?;"]
#[doc = " assert_eq!(None, ints);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_remove<Arr: ArrayOrNullableArray<Inner = T> + SingleValue,
    T: SingleValue, a, e>(a: a, e: e) -> array_remove<Arr, T, a, e> where
    a: diesel::expression::AsExpression<Arr>,
    e: diesel::expression::AsExpression<T> {
    array_remove_utils::array_remove {
        a: a.as_expression(),
        e: e.as_expression(),
        Arr: ::std::marker::PhantomData,
        T: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_remove()`](fn@array_remove)"]
pub type array_remove<Arr, T, a, e> =
    array_remove_utils::array_remove<Arr, T,
    <a as diesel::expression::AsExpression<Arr>>::Expression,
    <e as diesel::expression::AsExpression<T>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_remove_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_remove<Arr, T, a, e> {
        pub(in super) a: a,
        pub(in super) e: e,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
        pub(in super) T: ::std::marker::PhantomData<T>,
    }
    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<Arr, T, a, e, __Rhs> ::std::ops::Add<__Rhs> for
                array_remove<Arr, T, a, e> 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<Arr, T, a, e, __Rhs> ::std::ops::Sub<__Rhs> for
                array_remove<Arr, T, a, e> 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<Arr, T, a, e, __Rhs> ::std::ops::Mul<__Rhs> for
                array_remove<Arr, T, a, e> 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<Arr, T, a, e, __Rhs> ::std::ops::Div<__Rhs> for
                array_remove<Arr, T, a, e> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, T: ::core::fmt::Debug,
        a: ::core::fmt::Debug, e: ::core::fmt::Debug> ::core::fmt::Debug for
        array_remove<Arr, T, a, e> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "array_remove", "a", &self.a, "e", &self.e, "Arr", &self.Arr,
                "T", &&self.T)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, T: ::core::clone::Clone,
        a: ::core::clone::Clone, e: ::core::clone::Clone> ::core::clone::Clone
        for array_remove<Arr, T, a, e> {
        #[inline]
        fn clone(&self) -> array_remove<Arr, T, a, e> {
            array_remove {
                a: ::core::clone::Clone::clone(&self.a),
                e: ::core::clone::Clone::clone(&self.e),
                Arr: ::core::clone::Clone::clone(&self.Arr),
                T: ::core::clone::Clone::clone(&self.T),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, T: ::core::marker::Copy,
        a: ::core::marker::Copy, e: ::core::marker::Copy> ::core::marker::Copy
        for array_remove<Arr, T, a, e> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                T: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                e: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_remove<Arr, T, a, e>
                {
                type QueryId =
                    array_remove<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <T as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <e as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <e as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    || <T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            || <e as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_remove()`](fn@array_remove)"]
    pub type HelperType<Arr, T, a, e> =
        array_remove<Arr, T, <a as AsExpression<Arr>>::Expression,
        <e as AsExpression<T>>::Expression>;
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e> Expression for array_remove<Arr, T, a, e> where
        (a, e): Expression {
        type SqlType = Arr;
    }
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, __DieselInternal> SelectableExpression<__DieselInternal> for
        array_remove<Arr, T, a, e> where
        a: SelectableExpression<__DieselInternal>,
        e: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_remove<Arr, T, a, e> where a: AppearsOnTable<__DieselInternal>,
        e: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, __DieselInternal> FunctionFragment<__DieselInternal> for
        array_remove<Arr, T, a, e> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>, e: QueryFragment<__DieselInternal>
        {
        const FUNCTION_NAME: &'static str = "array_remove";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.e.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.e.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e> QueryFragment<crate::pg::Pg> for array_remove<Arr, T, a, e>
        where a: QueryFragment<crate::pg::Pg>, e: QueryFragment<crate::pg::Pg>
        {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, e>(a, e);
    const _: () =
        {
            use diesel;
            impl<a, e, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, e> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                e: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<e
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<e as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue,
        a, e, __DieselInternal> ValidGrouping<__DieselInternal> for
        array_remove<Arr, T, a, e> where
        __Derived<a, e>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, e> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Converts each array element to its text representation and concatenates those elements"]
#[doc =
" separated by the delimiter string. If `null_string` is provided and is not `NULL`, then `NULL`"]
#[doc =
" array entries are represented by that string; otherwise, they are omitted."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_to_string_with_null_string;"]
#[doc = " #     use diesel::sql_types::{Nullable, Text, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " // Example with `NULL` representation as a string"]
#[doc =
" let result: String = diesel::select(array_to_string_with_null_string::<"]
#[doc = "     Array<Nullable<Text>>,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = " >("]
#[doc = "     vec![Some(\"first\"), None::<&str>, Some(\"third\")],"]
#[doc = "     \",\","]
#[doc = "     \"NULL\","]
#[doc = " ))"]
#[doc = " .get_result(connection)?;"]
#[doc = " assert_eq!(result, \"first,NULL,third\");"]
#[doc = ""]
#[doc = " // Example without any `NULL` values"]
#[doc =
" let result: String = diesel::select(array_to_string_with_null_string::<"]
#[doc = "     Array<Nullable<Text>>,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = " >(vec![Some(\"first\"), Some(\"second\")], \",\", \"NULL\"))"]
#[doc = " .get_result(connection)?;"]
#[doc = " assert_eq!(result, \"first,second\");"]
#[doc = ""]
#[doc = " // Example with all `NULL` values"]
#[doc =
" let result: String = diesel::select(array_to_string_with_null_string::<"]
#[doc = "     Array<Nullable<Text>>,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = "     _,"]
#[doc = " >(vec![None::<&str>, None::<&str>], \",\", \"NULL\"))"]
#[doc = " .get_result(connection)?;"]
#[doc = " assert_eq!(result, \"NULL,NULL\");"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_to_string_with_null_string<Arr: ArrayOrNullableArray +
    SingleValue, array, del, null>(array: array, del: del, null: null)
    -> array_to_string_with_null_string<Arr, array, del, null> where
    array: diesel::expression::AsExpression<Arr>,
    del: diesel::expression::AsExpression<Text>,
    null: diesel::expression::AsExpression<Text> {
    array_to_string_with_null_string_utils::array_to_string_with_null_string {
        array: array.as_expression(),
        del: del.as_expression(),
        null: null.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`array_to_string_with_null_string()`](fn@array_to_string_with_null_string)"]
pub type array_to_string_with_null_string<Arr, array, del, null> =
    array_to_string_with_null_string_utils::array_to_string_with_null_string<Arr,
    <array as diesel::expression::AsExpression<Arr>>::Expression,
    <del as diesel::expression::AsExpression<Text>>::Expression,
    <null as diesel::expression::AsExpression<Text>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_to_string_with_null_string_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_to_string_with_null_string<Arr, array, del, null> {
        pub(in super) array: array,
        pub(in super) del: del,
        pub(in super) null: null,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, array, del, null, __Rhs> ::std::ops::Add<__Rhs> for
                array_to_string_with_null_string<Arr, array, del, null> 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<Arr, array, del, null, __Rhs> ::std::ops::Sub<__Rhs> for
                array_to_string_with_null_string<Arr, array, del, null> 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<Arr, array, del, null, __Rhs> ::std::ops::Mul<__Rhs> for
                array_to_string_with_null_string<Arr, array, del, null> 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<Arr, array, del, null, __Rhs> ::std::ops::Div<__Rhs> for
                array_to_string_with_null_string<Arr, array, del, null> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, array: ::core::fmt::Debug,
        del: ::core::fmt::Debug, null: ::core::fmt::Debug> ::core::fmt::Debug
        for array_to_string_with_null_string<Arr, array, del, null> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "array_to_string_with_null_string", "array", &self.array,
                "del", &self.del, "null", &self.null, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, array: ::core::clone::Clone,
        del: ::core::clone::Clone, null: ::core::clone::Clone>
        ::core::clone::Clone for
        array_to_string_with_null_string<Arr, array, del, null> {
        #[inline]
        fn clone(&self)
            -> array_to_string_with_null_string<Arr, array, del, null> {
            array_to_string_with_null_string {
                array: ::core::clone::Clone::clone(&self.array),
                del: ::core::clone::Clone::clone(&self.del),
                null: ::core::clone::Clone::clone(&self.null),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, array: ::core::marker::Copy,
        del: ::core::marker::Copy, null: ::core::marker::Copy>
        ::core::marker::Copy for
        array_to_string_with_null_string<Arr, array, del, null> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                array: diesel::query_builder::QueryId,
                del: diesel::query_builder::QueryId,
                null: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_to_string_with_null_string<Arr, array, del, null> {
                type QueryId =
                    array_to_string_with_null_string<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <array as diesel::query_builder::QueryId>::QueryId,
                    <del as diesel::query_builder::QueryId>::QueryId,
                    <null as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <array as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <del as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <null as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    ||
                                    <array as
                                        diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <del as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <null as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc =
    "The return type of [`array_to_string_with_null_string()`](fn@array_to_string_with_null_string)"]
    pub type HelperType<Arr, array, del, null> =
        array_to_string_with_null_string<Arr,
        <array as AsExpression<Arr>>::Expression,
        <del as AsExpression<Text>>::Expression,
        <null as AsExpression<Text>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del, null> Expression
        for array_to_string_with_null_string<Arr, array, del, null> where
        (array, del, null): Expression {
        type SqlType = Text;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del, null,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        array_to_string_with_null_string<Arr, array, del, null> where
        array: SelectableExpression<__DieselInternal>,
        del: SelectableExpression<__DieselInternal>,
        null: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del, null,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_to_string_with_null_string<Arr, array, del, null> where
        array: AppearsOnTable<__DieselInternal>,
        del: AppearsOnTable<__DieselInternal>,
        null: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del, null,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        array_to_string_with_null_string<Arr, array, del, null> where
        __DieselInternal: diesel::backend::Backend,
        array: QueryFragment<__DieselInternal>,
        del: QueryFragment<__DieselInternal>,
        null: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_to_string";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.del.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.del.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.null.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.null.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del, null>
        QueryFragment<crate::pg::Pg> for
        array_to_string_with_null_string<Arr, array, del, null> where
        array: QueryFragment<crate::pg::Pg>,
        del: QueryFragment<crate::pg::Pg>, null: QueryFragment<crate::pg::Pg>
        {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<array, del, null>(array, del, null);
    const _: () =
        {
            use diesel;
            impl<array, del, null, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<array, del, null> where
                array: diesel::expression::ValidGrouping<__GroupByClause>,
                del: diesel::expression::ValidGrouping<__GroupByClause>,
                null: diesel::expression::ValidGrouping<__GroupByClause>,
                <array as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<del
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<array as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<del as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<null
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<del as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<null as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del, null,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        array_to_string_with_null_string<Arr, array, del, null> where
        __Derived<array, del, null>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<array, del, null> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Converts each array element to its text representation and concatenates those elements"]
#[doc =
" separated by the delimiter string. `NULL` entries are omitted in this variant."]
#[doc =
" See [array_to_string_with_null_string](array_to_string_with_null_string()) for a variant with that argument."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_to_string;"]
#[doc = " #     use diesel::sql_types::{Text, Array, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " // Example with non-null values"]
#[doc =
" let result: String = diesel::select(array_to_string::<Array<Nullable<Text>>, _, _>("]
#[doc = "     vec![Some(\"first\"), Some(\"second\")],"]
#[doc = "     \",\","]
#[doc = " ))"]
#[doc = " .get_result(connection)?;"]
#[doc = " assert_eq!(result, \"first,second\");"]
#[doc = ""]
#[doc = " // Example with `NULL` values (omitted in the result)"]
#[doc =
" let result: String = diesel::select(array_to_string::<Array<Nullable<Text>>, _, _>("]
#[doc = "     vec![Some(\"first\"), None::<&str>, Some(\"third\")],"]
#[doc = "     \",\","]
#[doc = " ))"]
#[doc = " .get_result(connection)?;"]
#[doc = " assert_eq!(result, \"first,third\");"]
#[doc = ""]
#[doc = " // Example with only `NULL` values (empty result)"]
#[doc =
" let result: String = diesel::select(array_to_string::<Array<Nullable<Text>>, _, _>("]
#[doc = "     vec![None::<&str>, None::<&str>],"]
#[doc = "     \",\","]
#[doc = " ))"]
#[doc = " .get_result(connection)?;"]
#[doc = " assert_eq!(result, \"\");"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_to_string<Arr: ArrayOrNullableArray + SingleValue, array,
    del>(array: array, del: del) -> array_to_string<Arr, array, del> where
    array: diesel::expression::AsExpression<Arr>,
    del: diesel::expression::AsExpression<Text> {
    array_to_string_utils::array_to_string {
        array: array.as_expression(),
        del: del.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_to_string()`](fn@array_to_string)"]
pub type array_to_string<Arr, array, del> =
    array_to_string_utils::array_to_string<Arr,
    <array as diesel::expression::AsExpression<Arr>>::Expression,
    <del as diesel::expression::AsExpression<Text>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_to_string_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_to_string<Arr, array, del> {
        pub(in super) array: array,
        pub(in super) del: del,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, array, del, __Rhs> ::std::ops::Add<__Rhs> for
                array_to_string<Arr, array, del> 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<Arr, array, del, __Rhs> ::std::ops::Sub<__Rhs> for
                array_to_string<Arr, array, del> 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<Arr, array, del, __Rhs> ::std::ops::Mul<__Rhs> for
                array_to_string<Arr, array, del> 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<Arr, array, del, __Rhs> ::std::ops::Div<__Rhs> for
                array_to_string<Arr, array, del> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, array: ::core::fmt::Debug,
        del: ::core::fmt::Debug> ::core::fmt::Debug for
        array_to_string<Arr, array, del> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f,
                "array_to_string", "array", &self.array, "del", &self.del,
                "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, array: ::core::clone::Clone,
        del: ::core::clone::Clone> ::core::clone::Clone for
        array_to_string<Arr, array, del> {
        #[inline]
        fn clone(&self) -> array_to_string<Arr, array, del> {
            array_to_string {
                array: ::core::clone::Clone::clone(&self.array),
                del: ::core::clone::Clone::clone(&self.del),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, array: ::core::marker::Copy,
        del: ::core::marker::Copy> ::core::marker::Copy for
        array_to_string<Arr, array, del> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                array: diesel::query_builder::QueryId,
                del: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_to_string<Arr, array, del> {
                type QueryId =
                    array_to_string<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <array as diesel::query_builder::QueryId>::QueryId,
                    <del as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <array as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <del as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <array as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <del as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_to_string()`](fn@array_to_string)"]
    pub type HelperType<Arr, array, del> =
        array_to_string<Arr, <array as AsExpression<Arr>>::Expression,
        <del as AsExpression<Text>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del> Expression for
        array_to_string<Arr, array, del> where (array, del): Expression {
        type SqlType = Text;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        array_to_string<Arr, array, del> where
        array: SelectableExpression<__DieselInternal>,
        del: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_to_string<Arr, array, del> where
        array: AppearsOnTable<__DieselInternal>,
        del: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        array_to_string<Arr, array, del> where
        __DieselInternal: diesel::backend::Backend,
        array: QueryFragment<__DieselInternal>,
        del: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_to_string";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.del.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.del.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del>
        QueryFragment<crate::pg::Pg> for array_to_string<Arr, array, del>
        where array: QueryFragment<crate::pg::Pg>,
        del: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<array, del>(array, del);
    const _: () =
        {
            use diesel;
            impl<array, del, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<array, del> where
                array: diesel::expression::ValidGrouping<__GroupByClause>,
                del: diesel::expression::ValidGrouping<__GroupByClause>,
                <array as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<del
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<del as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, array, del,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        array_to_string<Arr, array, del> where
        __Derived<array, del>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<array, del> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Returns the total number of elements in the array, or 0 if the array is empty."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main(){"]
#[doc = " #    run_test().unwrap();"]
#[doc = " # }"]
#[doc = " # fn run_test()->QueryResult<()>{"]
#[doc = " #   use diesel::dsl::cardinality;"]
#[doc = " #   use diesel::sql_types::{Nullable,Array,Integer};"]
#[doc = " #   let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let array_cardinality = diesel::select(cardinality::<Array<Integer>, _>(vec![1, 2, 3, 4]))"]
#[doc = "     .get_result::<i32>(connection)?;"]
#[doc = " assert_eq!(4, array_cardinality);"]
#[doc = ""]
#[doc =
" let array_cardinality = diesel::select(cardinality::<Array<Nullable<Integer>>, _>(vec![Some(1), Some(2), Some(3)]))"]
#[doc = "     .get_result::<i32>(connection)?;"]
#[doc = " assert_eq!(3, array_cardinality);"]
#[doc = ""]
#[doc =
" let array_cardinality = diesel::select(cardinality::<Array<Integer>, _>(Vec::<i32>::new()))"]
#[doc = "     .get_result::<i32>(connection)?;"]
#[doc = " assert_eq!(0, array_cardinality);"]
#[doc = ""]
#[doc =
" let array_cardinality = diesel::select(cardinality::<Nullable<Array<Integer>>, _>(None::<Vec<i32>>))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, array_cardinality);"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[allow(non_camel_case_types)]
pub fn cardinality<Arr: ArrayOrNullableArray + SingleValue +
    MaybeNullableValue<Integer>, a>(a: a) -> cardinality<Arr, a> where
    a: diesel::expression::AsExpression<Arr> {
    cardinality_utils::cardinality {
        a: a.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`cardinality()`](fn@cardinality)"]
pub type cardinality<Arr, a> =
    cardinality_utils::cardinality<Arr,
    <a as diesel::expression::AsExpression<Arr>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod cardinality_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct cardinality<Arr, a> {
        pub(in super) a: a,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, a, __Rhs> ::std::ops::Add<__Rhs> for cardinality<Arr, a>
                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<Arr, a, __Rhs> ::std::ops::Sub<__Rhs> for cardinality<Arr, a>
                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<Arr, a, __Rhs> ::std::ops::Mul<__Rhs> for cardinality<Arr, a>
                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<Arr, a, __Rhs> ::std::ops::Div<__Rhs> for cardinality<Arr, a>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, a: ::core::fmt::Debug> ::core::fmt::Debug
        for cardinality<Arr, a> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "cardinality", "a", &self.a, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, a: ::core::clone::Clone>
        ::core::clone::Clone for cardinality<Arr, a> {
        #[inline]
        fn clone(&self) -> cardinality<Arr, a> {
            cardinality {
                a: ::core::clone::Clone::clone(&self.a),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, a: ::core::marker::Copy>
        ::core::marker::Copy for cardinality<Arr, a> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for cardinality<Arr, a> {
                type QueryId =
                    cardinality<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`cardinality()`](fn@cardinality)"]
    pub type HelperType<Arr, a> =
        cardinality<Arr, <a as AsExpression<Arr>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, a> Expression for cardinality<Arr, a>
        where (a): Expression {
        type SqlType = Arr::Out;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, a, __DieselInternal>
        SelectableExpression<__DieselInternal> for cardinality<Arr, a> where
        a: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, a, __DieselInternal>
        AppearsOnTable<__DieselInternal> for cardinality<Arr, a> where
        a: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, a, __DieselInternal>
        FunctionFragment<__DieselInternal> for cardinality<Arr, a> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "cardinality";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, a> QueryFragment<crate::pg::Pg> for
        cardinality<Arr, a> where a: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a>(a);
    const _: () =
        {
            use diesel;
            impl<a, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a> where
                a: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, a, __DieselInternal>
        ValidGrouping<__DieselInternal> for cardinality<Arr, a> where
        __Derived<a>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Trims an array by removing the last n elements. If the array is multidimensional, only the first dimension is trimmed."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main(){"]
#[doc = " #    run_test().unwrap();"]
#[doc = " # }"]
#[doc = " # fn run_test()->QueryResult<()>{"]
#[doc = " #   use diesel::dsl::trim_array;"]
#[doc = " #   use diesel::sql_types::{Nullable,Array,Integer};"]
#[doc = " #   let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let trimmed_array = diesel::select(trim_array::<Array<Integer>, _, _>(vec![1, 2, 3, 4], 3))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![1], trimmed_array);"]
#[doc = ""]
#[doc =
" let trimmed_array = diesel::select(trim_array::<Array<Nullable<Integer>>, _, _>(vec![Some(1), Some(2), Some(3)], 1))"]
#[doc = "     .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![Some(1), Some(2)], trimmed_array);"]
#[doc = ""]
#[doc =
" let trimmed_array = diesel::select(trim_array::<Array<Integer>, _, _>(Vec::<i32>::new(), 0))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(Vec::<i32>::new(), trimmed_array);"]
#[doc = ""]
#[doc =
" let trimmed_array = diesel::select(trim_array::<Nullable<Array<Integer>>, _, _>(None::<Vec<i32>>, 0))"]
#[doc = "     .get_result::<Option<Vec<i32>>>(connection)?;"]
#[doc = " assert_eq!(None, trimmed_array);"]
#[doc = ""]
#[doc =
" let trimmed_array = diesel::select(trim_array::<Nullable<Array<Integer>>, _, _>(None::<Vec<i32>>, 1))"]
#[doc = "     .get_result::<Option<Vec<i32>>>(connection)?;"]
#[doc = " assert_eq!(None, trimmed_array);"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[allow(non_camel_case_types)]
pub fn trim_array<Arr: ArrayOrNullableArray + SingleValue, a, n>(a: a, n: n)
    -> trim_array<Arr, a, n> where a: diesel::expression::AsExpression<Arr>,
    n: diesel::expression::AsExpression<Integer> {
    trim_array_utils::trim_array {
        a: a.as_expression(),
        n: n.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`trim_array()`](fn@trim_array)"]
pub type trim_array<Arr, a, n> =
    trim_array_utils::trim_array<Arr,
    <a as diesel::expression::AsExpression<Arr>>::Expression,
    <n as diesel::expression::AsExpression<Integer>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod trim_array_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct trim_array<Arr, a, n> {
        pub(in super) a: a,
        pub(in super) n: n,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, a, n, __Rhs> ::std::ops::Add<__Rhs> for
                trim_array<Arr, a, n> 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<Arr, a, n, __Rhs> ::std::ops::Sub<__Rhs> for
                trim_array<Arr, a, n> 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<Arr, a, n, __Rhs> ::std::ops::Mul<__Rhs> for
                trim_array<Arr, a, n> 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<Arr, a, n, __Rhs> ::std::ops::Div<__Rhs> for
                trim_array<Arr, a, n> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, a: ::core::fmt::Debug,
        n: ::core::fmt::Debug> ::core::fmt::Debug for trim_array<Arr, a, n> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f,
                "trim_array", "a", &self.a, "n", &self.n, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, a: ::core::clone::Clone,
        n: ::core::clone::Clone> ::core::clone::Clone for
        trim_array<Arr, a, n> {
        #[inline]
        fn clone(&self) -> trim_array<Arr, a, n> {
            trim_array {
                a: ::core::clone::Clone::clone(&self.a),
                n: ::core::clone::Clone::clone(&self.n),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, a: ::core::marker::Copy,
        n: ::core::marker::Copy> ::core::marker::Copy for
        trim_array<Arr, a, n> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                n: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for trim_array<Arr, a, n> {
                type QueryId =
                    trim_array<<Arr as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <n as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <n as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            || <n as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`trim_array()`](fn@trim_array)"]
    pub type HelperType<Arr, a, n> =
        trim_array<Arr, <a as AsExpression<Arr>>::Expression,
        <n as AsExpression<Integer>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, a, n> Expression for
        trim_array<Arr, a, n> where (a, n): Expression {
        type SqlType = Arr;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, a, n, __DieselInternal>
        SelectableExpression<__DieselInternal> for trim_array<Arr, a, n> where
        a: SelectableExpression<__DieselInternal>,
        n: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, a, n, __DieselInternal>
        AppearsOnTable<__DieselInternal> for trim_array<Arr, a, n> where
        a: AppearsOnTable<__DieselInternal>,
        n: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, a, n, __DieselInternal>
        FunctionFragment<__DieselInternal> for trim_array<Arr, a, n> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>, n: QueryFragment<__DieselInternal>
        {
        const FUNCTION_NAME: &'static str = "trim_array";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.n.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.n.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, a, n>
        QueryFragment<crate::pg::Pg> for trim_array<Arr, a, n> where
        a: QueryFragment<crate::pg::Pg>, n: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, n>(a, n);
    const _: () =
        {
            use diesel;
            impl<a, n, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, n> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                n: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<n
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<n as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, a, n, __DieselInternal>
        ValidGrouping<__DieselInternal> for trim_array<Arr, a, n> where
        __Derived<a, n>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, n> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Concatenates two arrays"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_cat;"]
#[doc = " #     use diesel::sql_types::{Integer, Array, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let result = diesel::select(array_cat::<Array<Integer>, _, _>(vec![1, 2], vec![3, 4]))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![1, 2, 3, 4], result);"]
#[doc = ""]
#[doc =
" let nullable_result = diesel::select(array_cat::<Nullable<Array<Integer>>, _, _>("]
#[doc = "     None::<Vec<i32>>,"]
#[doc = "     None::<Vec<i32>>,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<Vec<i32>>>(connection)?;"]
#[doc = " assert_eq!(None, nullable_result);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_cat<Arr: ArrayOrNullableArray + SingleValue, a, b>(a: a, b: b)
    -> array_cat<Arr, a, b> where a: diesel::expression::AsExpression<Arr>,
    b: diesel::expression::AsExpression<Arr> {
    array_cat_utils::array_cat {
        a: a.as_expression(),
        b: b.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_cat()`](fn@array_cat)"]
pub type array_cat<Arr, a, b> =
    array_cat_utils::array_cat<Arr,
    <a as diesel::expression::AsExpression<Arr>>::Expression,
    <b as diesel::expression::AsExpression<Arr>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_cat_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_cat<Arr, a, b> {
        pub(in super) a: a,
        pub(in super) b: b,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, a, b, __Rhs> ::std::ops::Add<__Rhs> for
                array_cat<Arr, a, b> 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<Arr, a, b, __Rhs> ::std::ops::Sub<__Rhs> for
                array_cat<Arr, a, b> 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<Arr, a, b, __Rhs> ::std::ops::Mul<__Rhs> for
                array_cat<Arr, a, b> 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<Arr, a, b, __Rhs> ::std::ops::Div<__Rhs> for
                array_cat<Arr, a, b> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, a: ::core::fmt::Debug,
        b: ::core::fmt::Debug> ::core::fmt::Debug for array_cat<Arr, a, b> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f, "array_cat",
                "a", &self.a, "b", &self.b, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, a: ::core::clone::Clone,
        b: ::core::clone::Clone> ::core::clone::Clone for array_cat<Arr, a, b>
        {
        #[inline]
        fn clone(&self) -> array_cat<Arr, a, b> {
            array_cat {
                a: ::core::clone::Clone::clone(&self.a),
                b: ::core::clone::Clone::clone(&self.b),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, a: ::core::marker::Copy,
        b: ::core::marker::Copy> ::core::marker::Copy for array_cat<Arr, a, b>
        {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                b: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_cat<Arr, a, b> {
                type QueryId =
                    array_cat<<Arr as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <b as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <b as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            || <b as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_cat()`](fn@array_cat)"]
    pub type HelperType<Arr, a, b> =
        array_cat<Arr, <a as AsExpression<Arr>>::Expression,
        <b as AsExpression<Arr>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, a, b> Expression for
        array_cat<Arr, a, b> where (a, b): Expression {
        type SqlType = Arr;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, a, b, __DieselInternal>
        SelectableExpression<__DieselInternal> for array_cat<Arr, a, b> where
        a: SelectableExpression<__DieselInternal>,
        b: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, a, b, __DieselInternal>
        AppearsOnTable<__DieselInternal> for array_cat<Arr, a, b> where
        a: AppearsOnTable<__DieselInternal>,
        b: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, a, b, __DieselInternal>
        FunctionFragment<__DieselInternal> for array_cat<Arr, a, b> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>, b: QueryFragment<__DieselInternal>
        {
        const FUNCTION_NAME: &'static str = "array_cat";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.b.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.b.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, a, b>
        QueryFragment<crate::pg::Pg> for array_cat<Arr, a, b> where
        a: QueryFragment<crate::pg::Pg>, b: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, b>(a, b);
    const _: () =
        {
            use diesel;
            impl<a, b, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, b> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                b: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<b
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<b as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, a, b, __DieselInternal>
        ValidGrouping<__DieselInternal> for array_cat<Arr, a, b> where
        __Derived<a, b>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, b> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the length of the requested array"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_length;"]
#[doc = " #     use diesel::sql_types::{Integer, Array, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let result = diesel::select(array_length::<Array<Integer>, _, _>(vec![1, 2, 3], 1))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(3), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(array_length::<Array<Integer>, _, _>(vec![1, 2, 3], 2))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(array_length::<Nullable<Array<Integer>>, _, _>("]
#[doc = "     None::<Vec<i32>>,"]
#[doc = "     1,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_length<Arr: ArrayOrNullableArray + SingleValue, array,
    dimension>(array: array, dimension: dimension)
    -> array_length<Arr, array, dimension> where
    array: diesel::expression::AsExpression<Arr>,
    dimension: diesel::expression::AsExpression<Integer> {
    array_length_utils::array_length {
        array: array.as_expression(),
        dimension: dimension.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_length()`](fn@array_length)"]
pub type array_length<Arr, array, dimension> =
    array_length_utils::array_length<Arr,
    <array as diesel::expression::AsExpression<Arr>>::Expression,
    <dimension as diesel::expression::AsExpression<Integer>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_length_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_length<Arr, array, dimension> {
        pub(in super) array: array,
        pub(in super) dimension: dimension,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, array, dimension, __Rhs> ::std::ops::Add<__Rhs> for
                array_length<Arr, array, dimension> 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<Arr, array, dimension, __Rhs> ::std::ops::Sub<__Rhs> for
                array_length<Arr, array, dimension> 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<Arr, array, dimension, __Rhs> ::std::ops::Mul<__Rhs> for
                array_length<Arr, array, dimension> 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<Arr, array, dimension, __Rhs> ::std::ops::Div<__Rhs> for
                array_length<Arr, array, dimension> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, array: ::core::fmt::Debug,
        dimension: ::core::fmt::Debug> ::core::fmt::Debug for
        array_length<Arr, array, dimension> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f,
                "array_length", "array", &self.array, "dimension",
                &self.dimension, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, array: ::core::clone::Clone,
        dimension: ::core::clone::Clone> ::core::clone::Clone for
        array_length<Arr, array, dimension> {
        #[inline]
        fn clone(&self) -> array_length<Arr, array, dimension> {
            array_length {
                array: ::core::clone::Clone::clone(&self.array),
                dimension: ::core::clone::Clone::clone(&self.dimension),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, array: ::core::marker::Copy,
        dimension: ::core::marker::Copy> ::core::marker::Copy for
        array_length<Arr, array, dimension> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                array: diesel::query_builder::QueryId,
                dimension: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_length<Arr, array, dimension> {
                type QueryId =
                    array_length<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <array as diesel::query_builder::QueryId>::QueryId,
                    <dimension as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <array as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <dimension as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <array as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <dimension as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`array_length()`](fn@array_length)"]
    pub type HelperType<Arr, array, dimension> =
        array_length<Arr, <array as AsExpression<Arr>>::Expression,
        <dimension as AsExpression<Integer>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension> Expression
        for array_length<Arr, array, dimension> where
        (array, dimension): Expression {
        type SqlType = Nullable<Integer>;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        array_length<Arr, array, dimension> where
        array: SelectableExpression<__DieselInternal>,
        dimension: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_length<Arr, array, dimension> where
        array: AppearsOnTable<__DieselInternal>,
        dimension: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        array_length<Arr, array, dimension> where
        __DieselInternal: diesel::backend::Backend,
        array: QueryFragment<__DieselInternal>,
        dimension: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_length";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.dimension.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.dimension.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension>
        QueryFragment<crate::pg::Pg> for array_length<Arr, array, dimension>
        where array: QueryFragment<crate::pg::Pg>,
        dimension: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<array, dimension>(array, dimension);
    const _: () =
        {
            use diesel;
            impl<array, dimension, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<array, dimension> where
                array: diesel::expression::ValidGrouping<__GroupByClause>,
                dimension: diesel::expression::ValidGrouping<__GroupByClause>,
                <array as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<dimension
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<dimension as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        array_length<Arr, array, dimension> where
        __Derived<array, dimension>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<array, dimension> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns an array initialized with supplied value and dimensions,"]
#[doc =
" optionally with lower bounds other than 1. This function omits the optional"]
#[doc =
" lower bound argument. See [array_fill_with_lower_bound](array_fill_with_lower_bound()) for that."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main(){"]
#[doc = " #    run_test().unwrap();"]
#[doc = " # }"]
#[doc = " # fn run_test()->QueryResult<()>{"]
#[doc = " #   use diesel::dsl::array_fill;"]
#[doc = " #   use diesel::sql_types::{Nullable,Array,Integer,Text};"]
#[doc = " #   let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let array = diesel::select(array_fill::<Integer,_,_>(2,vec![2]))"]
#[doc = " .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![2,2],array);"]
#[doc = ""]
#[doc =
" let array = diesel::select(array_fill::<Text,_,_>(String::from(\"abc\"),vec![3]))"]
#[doc = " .get_result::<Vec<String>>(connection)?;"]
#[doc = " assert_eq!(vec![\"abc\",\"abc\",\"abc\"],array);"]
#[doc = ""]
#[doc =
" let array = diesel::select(array_fill::<Nullable<Integer>,_,_>(Some(4),vec![3]))"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![Some(4),Some(4),Some(4)],array);"]
#[doc = ""]
#[doc =
" let array = diesel::select(array_fill::<Nullable<Integer>,_,_>(None::<i32>,vec![3]))"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![None::<i32>,None::<i32>,None::<i32>],array);"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[allow(non_camel_case_types)]
pub fn array_fill<E: SingleValue, value, dim>(value: value, dim: dim)
    -> array_fill<E, value, dim> where
    value: diesel::expression::AsExpression<E>,
    dim: diesel::expression::AsExpression<Array<Integer>> {
    array_fill_utils::array_fill {
        value: value.as_expression(),
        dim: dim.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_fill()`](fn@array_fill)"]
pub type array_fill<E, value, dim> =
    array_fill_utils::array_fill<E,
    <value as diesel::expression::AsExpression<E>>::Expression,
    <dim as diesel::expression::AsExpression<Array<Integer>>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_fill_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_fill<E, value, dim> {
        pub(in super) value: value,
        pub(in super) dim: dim,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, value, dim, __Rhs> ::std::ops::Add<__Rhs> for
                array_fill<E, value, dim> 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<E, value, dim, __Rhs> ::std::ops::Sub<__Rhs> for
                array_fill<E, value, dim> 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<E, value, dim, __Rhs> ::std::ops::Mul<__Rhs> for
                array_fill<E, value, dim> 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<E, value, dim, __Rhs> ::std::ops::Div<__Rhs> for
                array_fill<E, value, dim> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, value: ::core::fmt::Debug,
        dim: ::core::fmt::Debug> ::core::fmt::Debug for
        array_fill<E, value, dim> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f,
                "array_fill", "value", &self.value, "dim", &self.dim, "E",
                &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, value: ::core::clone::Clone,
        dim: ::core::clone::Clone> ::core::clone::Clone for
        array_fill<E, value, dim> {
        #[inline]
        fn clone(&self) -> array_fill<E, value, dim> {
            array_fill {
                value: ::core::clone::Clone::clone(&self.value),
                dim: ::core::clone::Clone::clone(&self.dim),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, value: ::core::marker::Copy,
        dim: ::core::marker::Copy> ::core::marker::Copy for
        array_fill<E, value, dim> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                value: diesel::query_builder::QueryId,
                dim: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_fill<E, value, dim> {
                type QueryId =
                    array_fill<<E as diesel::query_builder::QueryId>::QueryId,
                    <value as diesel::query_builder::QueryId>::QueryId,
                    <dim as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <value as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <dim as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <value as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <dim as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_fill()`](fn@array_fill)"]
    pub type HelperType<E, value, dim> =
        array_fill<E, <value as AsExpression<E>>::Expression,
        <dim as AsExpression<Array<Integer>>>::Expression>;
    impl<E: SingleValue, value, dim> Expression for array_fill<E, value, dim>
        where (value, dim): Expression {
        type SqlType = Array<E>;
    }
    impl<E: SingleValue, value, dim, __DieselInternal>
        SelectableExpression<__DieselInternal> for array_fill<E, value, dim>
        where value: SelectableExpression<__DieselInternal>,
        dim: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: SingleValue, value, dim, __DieselInternal>
        AppearsOnTable<__DieselInternal> for array_fill<E, value, dim> where
        value: AppearsOnTable<__DieselInternal>,
        dim: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: SingleValue, value, dim, __DieselInternal>
        FunctionFragment<__DieselInternal> for array_fill<E, value, dim> where
        __DieselInternal: diesel::backend::Backend,
        value: QueryFragment<__DieselInternal>,
        dim: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_fill";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.value.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.value.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.dim.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.dim.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: SingleValue, value, dim> QueryFragment<crate::pg::Pg> for
        array_fill<E, value, dim> where value: QueryFragment<crate::pg::Pg>,
        dim: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<value, dim>(value, dim);
    const _: () =
        {
            use diesel;
            impl<value, dim, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<value, dim> where
                value: diesel::expression::ValidGrouping<__GroupByClause>,
                dim: diesel::expression::ValidGrouping<__GroupByClause>,
                <value as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<dim
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<value as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<dim as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<E: SingleValue, value, dim, __DieselInternal>
        ValidGrouping<__DieselInternal> for array_fill<E, value, dim> where
        __Derived<value, dim>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<value, dim> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns an array initialized with supplied value and dimensions,"]
#[doc = " with lower bounds other than 1"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main(){"]
#[doc = " #    run_test().unwrap();"]
#[doc = " # }"]
#[doc = " # fn run_test()->QueryResult<()>{"]
#[doc = " #   use diesel::dsl::array_fill_with_lower_bound;"]
#[doc = " #   use diesel::sql_types::{Nullable,Array,Integer,Text};"]
#[doc = " #   let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let array = diesel::select(array_fill_with_lower_bound::<Integer,_,_,_>(2,vec![2],vec![2]))"]
#[doc = " .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![2,2],array);"]
#[doc = ""]
#[doc =
" let array = diesel::select(array_fill_with_lower_bound::<Text,_,_,_>(String::from(\"abc\"),vec![3],vec![3]))"]
#[doc = " .get_result::<Vec<String>>(connection)?;"]
#[doc = " assert_eq!(vec![\"abc\",\"abc\",\"abc\"],array);"]
#[doc = ""]
#[doc =
" let array = diesel::select(array_fill_with_lower_bound::<Nullable<Integer>,_,_,_>(Some(4),vec![3],vec![3]))"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![Some(4),Some(4),Some(4)],array);"]
#[doc = ""]
#[doc =
" let array = diesel::select(array_fill_with_lower_bound::<Nullable<Integer>,_,_,_>(None::<i32>,vec![3],vec![3]))"]
#[doc = " .get_result::<Vec<Option<i32>>>(connection)?;"]
#[doc = " assert_eq!(vec![None::<i32>,None::<i32>,None::<i32>],array);"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[allow(non_camel_case_types)]
pub fn array_fill_with_lower_bound<E: SingleValue, value, dim,
    lower_bound>(value: value, dim: dim, lower_bound: lower_bound)
    -> array_fill_with_lower_bound<E, value, dim, lower_bound> where
    value: diesel::expression::AsExpression<E>,
    dim: diesel::expression::AsExpression<Array<Integer>>,
    lower_bound: diesel::expression::AsExpression<Array<Integer>> {
    array_fill_with_lower_bound_utils::array_fill_with_lower_bound {
        value: value.as_expression(),
        dim: dim.as_expression(),
        lower_bound: lower_bound.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`array_fill_with_lower_bound()`](fn@array_fill_with_lower_bound)"]
pub type array_fill_with_lower_bound<E, value, dim, lower_bound> =
    array_fill_with_lower_bound_utils::array_fill_with_lower_bound<E,
    <value as diesel::expression::AsExpression<E>>::Expression,
    <dim as diesel::expression::AsExpression<Array<Integer>>>::Expression,
    <lower_bound as
    diesel::expression::AsExpression<Array<Integer>>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_fill_with_lower_bound_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_fill_with_lower_bound<E, value, dim, lower_bound> {
        pub(in super) value: value,
        pub(in super) dim: dim,
        pub(in super) lower_bound: lower_bound,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, value, dim, lower_bound, __Rhs> ::std::ops::Add<__Rhs> for
                array_fill_with_lower_bound<E, value, dim, lower_bound> 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<E, value, dim, lower_bound, __Rhs> ::std::ops::Sub<__Rhs> for
                array_fill_with_lower_bound<E, value, dim, lower_bound> 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<E, value, dim, lower_bound, __Rhs> ::std::ops::Mul<__Rhs> for
                array_fill_with_lower_bound<E, value, dim, lower_bound> 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<E, value, dim, lower_bound, __Rhs> ::std::ops::Div<__Rhs> for
                array_fill_with_lower_bound<E, value, dim, lower_bound> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, value: ::core::fmt::Debug,
        dim: ::core::fmt::Debug, lower_bound: ::core::fmt::Debug>
        ::core::fmt::Debug for
        array_fill_with_lower_bound<E, value, dim, lower_bound> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "array_fill_with_lower_bound", "value", &self.value, "dim",
                &self.dim, "lower_bound", &self.lower_bound, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, value: ::core::clone::Clone,
        dim: ::core::clone::Clone, lower_bound: ::core::clone::Clone>
        ::core::clone::Clone for
        array_fill_with_lower_bound<E, value, dim, lower_bound> {
        #[inline]
        fn clone(&self)
            -> array_fill_with_lower_bound<E, value, dim, lower_bound> {
            array_fill_with_lower_bound {
                value: ::core::clone::Clone::clone(&self.value),
                dim: ::core::clone::Clone::clone(&self.dim),
                lower_bound: ::core::clone::Clone::clone(&self.lower_bound),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, value: ::core::marker::Copy,
        dim: ::core::marker::Copy, lower_bound: ::core::marker::Copy>
        ::core::marker::Copy for
        array_fill_with_lower_bound<E, value, dim, lower_bound> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                value: diesel::query_builder::QueryId,
                dim: diesel::query_builder::QueryId,
                lower_bound: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_fill_with_lower_bound<E, value, dim, lower_bound> {
                type QueryId =
                    array_fill_with_lower_bound<<E as
                    diesel::query_builder::QueryId>::QueryId,
                    <value as diesel::query_builder::QueryId>::QueryId,
                    <dim as diesel::query_builder::QueryId>::QueryId,
                    <lower_bound as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <value as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <dim as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <lower_bound as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                    <value as
                                        diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <dim as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <lower_bound as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`array_fill_with_lower_bound()`](fn@array_fill_with_lower_bound)"]
    pub type HelperType<E, value, dim, lower_bound> =
        array_fill_with_lower_bound<E, <value as AsExpression<E>>::Expression,
        <dim as AsExpression<Array<Integer>>>::Expression,
        <lower_bound as AsExpression<Array<Integer>>>::Expression>;
    impl<E: SingleValue, value, dim, lower_bound> Expression for
        array_fill_with_lower_bound<E, value, dim, lower_bound> where
        (value, dim, lower_bound): Expression {
        type SqlType = Array<E>;
    }
    impl<E: SingleValue, value, dim, lower_bound, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        array_fill_with_lower_bound<E, value, dim, lower_bound> where
        value: SelectableExpression<__DieselInternal>,
        dim: SelectableExpression<__DieselInternal>,
        lower_bound: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: SingleValue, value, dim, lower_bound, __DieselInternal>
        AppearsOnTable<__DieselInternal> for
        array_fill_with_lower_bound<E, value, dim, lower_bound> where
        value: AppearsOnTable<__DieselInternal>,
        dim: AppearsOnTable<__DieselInternal>,
        lower_bound: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: SingleValue, value, dim, lower_bound, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        array_fill_with_lower_bound<E, value, dim, lower_bound> where
        __DieselInternal: diesel::backend::Backend,
        value: QueryFragment<__DieselInternal>,
        dim: QueryFragment<__DieselInternal>,
        lower_bound: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_fill";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.value.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.value.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.dim.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.dim.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.lower_bound.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.lower_bound.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: SingleValue, value, dim, lower_bound> QueryFragment<crate::pg::Pg>
        for array_fill_with_lower_bound<E, value, dim, lower_bound> where
        value: QueryFragment<crate::pg::Pg>,
        dim: QueryFragment<crate::pg::Pg>,
        lower_bound: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<value, dim, lower_bound>(value, dim, lower_bound);
    const _: () =
        {
            use diesel;
            impl<value, dim, lower_bound, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<value, dim, lower_bound> where
                value: diesel::expression::ValidGrouping<__GroupByClause>,
                dim: diesel::expression::ValidGrouping<__GroupByClause>,
                lower_bound: diesel::expression::ValidGrouping<__GroupByClause>,
                <value as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<dim
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<value as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<dim as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<lower_bound
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<value as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<dim as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<lower_bound as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<E: SingleValue, value, dim, lower_bound, __DieselInternal>
        ValidGrouping<__DieselInternal> for
        array_fill_with_lower_bound<E, value, dim, lower_bound> where
        __Derived<value, dim, lower_bound>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<value, dim, lower_bound> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the lower bound of the requested array"]
#[doc = ""]
#[doc = " This function returns null for dimensions that do not exist"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_lower;"]
#[doc = " #     use diesel::sql_types::{Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let result = diesel::select(array_lower::<Array<Integer>, _, _>(vec![1, 2, 3], 1))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(1), result);"]
#[doc = ""]
#[doc = " // the array has only one dimension"]
#[doc =
" let result = diesel::select(array_lower::<Array<Integer>, _, _>(vec![1, 2, 3], 2))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_lower<Arr: ArrayOrNullableArray + SingleValue, array,
    dimension>(array: array, dimension: dimension)
    -> array_lower<Arr, array, dimension> where
    array: diesel::expression::AsExpression<Arr>,
    dimension: diesel::expression::AsExpression<Integer> {
    array_lower_utils::array_lower {
        array: array.as_expression(),
        dimension: dimension.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_lower()`](fn@array_lower)"]
pub type array_lower<Arr, array, dimension> =
    array_lower_utils::array_lower<Arr,
    <array as diesel::expression::AsExpression<Arr>>::Expression,
    <dimension as diesel::expression::AsExpression<Integer>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_lower_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_lower<Arr, array, dimension> {
        pub(in super) array: array,
        pub(in super) dimension: dimension,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, array, dimension, __Rhs> ::std::ops::Add<__Rhs> for
                array_lower<Arr, array, dimension> 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<Arr, array, dimension, __Rhs> ::std::ops::Sub<__Rhs> for
                array_lower<Arr, array, dimension> 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<Arr, array, dimension, __Rhs> ::std::ops::Mul<__Rhs> for
                array_lower<Arr, array, dimension> 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<Arr, array, dimension, __Rhs> ::std::ops::Div<__Rhs> for
                array_lower<Arr, array, dimension> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, array: ::core::fmt::Debug,
        dimension: ::core::fmt::Debug> ::core::fmt::Debug for
        array_lower<Arr, array, dimension> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f,
                "array_lower", "array", &self.array, "dimension",
                &self.dimension, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, array: ::core::clone::Clone,
        dimension: ::core::clone::Clone> ::core::clone::Clone for
        array_lower<Arr, array, dimension> {
        #[inline]
        fn clone(&self) -> array_lower<Arr, array, dimension> {
            array_lower {
                array: ::core::clone::Clone::clone(&self.array),
                dimension: ::core::clone::Clone::clone(&self.dimension),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, array: ::core::marker::Copy,
        dimension: ::core::marker::Copy> ::core::marker::Copy for
        array_lower<Arr, array, dimension> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                array: diesel::query_builder::QueryId,
                dimension: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_lower<Arr, array, dimension> {
                type QueryId =
                    array_lower<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <array as diesel::query_builder::QueryId>::QueryId,
                    <dimension as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <array as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <dimension as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <array as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <dimension as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`array_lower()`](fn@array_lower)"]
    pub type HelperType<Arr, array, dimension> =
        array_lower<Arr, <array as AsExpression<Arr>>::Expression,
        <dimension as AsExpression<Integer>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension> Expression
        for array_lower<Arr, array, dimension> where
        (array, dimension): Expression {
        type SqlType = Nullable<Integer>;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        array_lower<Arr, array, dimension> where
        array: SelectableExpression<__DieselInternal>,
        dimension: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_lower<Arr, array, dimension> where
        array: AppearsOnTable<__DieselInternal>,
        dimension: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        array_lower<Arr, array, dimension> where
        __DieselInternal: diesel::backend::Backend,
        array: QueryFragment<__DieselInternal>,
        dimension: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_lower";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.dimension.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.dimension.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension>
        QueryFragment<crate::pg::Pg> for array_lower<Arr, array, dimension>
        where array: QueryFragment<crate::pg::Pg>,
        dimension: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<array, dimension>(array, dimension);
    const _: () =
        {
            use diesel;
            impl<array, dimension, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<array, dimension> where
                array: diesel::expression::ValidGrouping<__GroupByClause>,
                dimension: diesel::expression::ValidGrouping<__GroupByClause>,
                <array as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<dimension
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<dimension as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        array_lower<Arr, array, dimension> where
        __Derived<array, dimension>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<array, dimension> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Returns the subscript of the first occurrence of the second argument in the array, or NULL if it\'s not present."]
#[doc =
" If the third argument is given, the search begins at that subscript. This function omits the third argument."]
#[doc =
" See [array_position_with_subscript](array_position_with_subscript())."]
#[doc = ""]
#[doc =
" The array must be one-dimensional. Comparisons are done using IS NOT DISTINCT FROM semantics,"]
#[doc = " so it is possible to search for NULL."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main(){"]
#[doc = " #    run_test().unwrap();"]
#[doc = " # }"]
#[doc = " # fn run_test()->QueryResult<()>{"]
#[doc = " #   use diesel::dsl::array_position;"]
#[doc = " #   use diesel::sql_types::{Nullable,Array,Integer};"]
#[doc = " #   let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_position::<Array<_>, Integer, _, _>(vec![1, 2, 3, 4], 3))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(3), pos);"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_position::<Array<_>, Integer, _, _>(vec![1, 2, 3, 4], 5))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None::<i32>, pos);"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_position::<Array<_>, Nullable<Integer>, _, _>("]
#[doc = "     vec![1, 2, 3, 4], None::<i32>))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None::<i32>, pos);"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_position::<Array<_>, Nullable<Integer>, _, _>("]
#[doc = "     vec![None::<i32>, Some(1), Some(2), Some(3)], None::<i32>))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(1), pos);"]
#[doc = ""]
#[doc =
" let dims = diesel::select(array_position::<Nullable<Array<Integer>>, Integer, _, _>(None::<Vec<i32>>, 1))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, dims);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[allow(non_camel_case_types)]
pub fn array_position<Arr: ArrayOrNullableArray<Inner = E> + SingleValue,
    E: SingleValue, a, elem>(a: a, elem: elem)
    -> array_position<Arr, E, a, elem> where
    a: diesel::expression::AsExpression<Arr>,
    elem: diesel::expression::AsExpression<E> {
    array_position_utils::array_position {
        a: a.as_expression(),
        elem: elem.as_expression(),
        Arr: ::std::marker::PhantomData,
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_position()`](fn@array_position)"]
pub type array_position<Arr, E, a, elem> =
    array_position_utils::array_position<Arr, E,
    <a as diesel::expression::AsExpression<Arr>>::Expression,
    <elem as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_position_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_position<Arr, E, a, elem> {
        pub(in super) a: a,
        pub(in super) elem: elem,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<Arr, E, a, elem, __Rhs> ::std::ops::Add<__Rhs> for
                array_position<Arr, E, a, elem> 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<Arr, E, a, elem, __Rhs> ::std::ops::Sub<__Rhs> for
                array_position<Arr, E, a, elem> 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<Arr, E, a, elem, __Rhs> ::std::ops::Mul<__Rhs> for
                array_position<Arr, E, a, elem> 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<Arr, E, a, elem, __Rhs> ::std::ops::Div<__Rhs> for
                array_position<Arr, E, a, elem> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, E: ::core::fmt::Debug,
        a: ::core::fmt::Debug, elem: ::core::fmt::Debug> ::core::fmt::Debug
        for array_position<Arr, E, a, elem> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "array_position", "a", &self.a, "elem", &self.elem, "Arr",
                &self.Arr, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, E: ::core::clone::Clone,
        a: ::core::clone::Clone, elem: ::core::clone::Clone>
        ::core::clone::Clone for array_position<Arr, E, a, elem> {
        #[inline]
        fn clone(&self) -> array_position<Arr, E, a, elem> {
            array_position {
                a: ::core::clone::Clone::clone(&self.a),
                elem: ::core::clone::Clone::clone(&self.elem),
                Arr: ::core::clone::Clone::clone(&self.Arr),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, E: ::core::marker::Copy,
        a: ::core::marker::Copy, elem: ::core::marker::Copy>
        ::core::marker::Copy for array_position<Arr, E, a, elem> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                E: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                elem: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_position<Arr, E, a, elem> {
                type QueryId =
                    array_position<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <E as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <elem as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <elem as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    || <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <elem as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_position()`](fn@array_position)"]
    pub type HelperType<Arr, E, a, elem> =
        array_position<Arr, E, <a as AsExpression<Arr>>::Expression,
        <elem as AsExpression<E>>::Expression>;
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem> Expression for array_position<Arr, E, a, elem> where
        (a, elem): Expression {
        type SqlType = Nullable<Integer>;
    }
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, __DieselInternal> SelectableExpression<__DieselInternal> for
        array_position<Arr, E, a, elem> where
        a: SelectableExpression<__DieselInternal>,
        elem: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_position<Arr, E, a, elem> where
        a: AppearsOnTable<__DieselInternal>,
        elem: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, __DieselInternal> FunctionFragment<__DieselInternal> for
        array_position<Arr, E, a, elem> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>,
        elem: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_position";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.elem.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.elem.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem> QueryFragment<crate::pg::Pg> for
        array_position<Arr, E, a, elem> where a: QueryFragment<crate::pg::Pg>,
        elem: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, elem>(a, elem);
    const _: () =
        {
            use diesel;
            impl<a, elem, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, elem> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                elem: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<elem
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<elem as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, __DieselInternal> ValidGrouping<__DieselInternal> for
        array_position<Arr, E, a, elem> where
        __Derived<a, elem>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, elem> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Returns the subscript of the first occurrence of the second argument in the array,"]
#[doc =
" or NULL if it\'s not present, beginning at the subscript given as the third argument."]
#[doc = ""]
#[doc = " The array must be one-dimensional."]
#[doc = " Comparisons are done using IS NOT DISTINCT FROM semantics,"]
#[doc = " so it is possible to search for NULL."]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main(){"]
#[doc = " #    run_test().unwrap();"]
#[doc = " # }"]
#[doc = " # fn run_test()->QueryResult<()>{"]
#[doc = " #   use diesel::dsl::array_position_with_subscript;"]
#[doc = " #   use diesel::sql_types::{Nullable,Array,Integer};"]
#[doc = " #   let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_position_with_subscript::<Array<_>, Integer, _, _, _>("]
#[doc = "     vec![1, 2, 3, 4], 3, 2))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(3), pos);"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_position_with_subscript::<Array<_>, Integer, _, _, _>("]
#[doc = "     vec![1, 2, 3, 4], 1, 2))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None::<i32>, pos);"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_position_with_subscript::<Array<_>, Nullable<Integer>, _, _, _>("]
#[doc = "     vec![None::<i32>, Some(1), Some(2), Some(3)], None::<i32>, 1))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(1), pos);"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_position_with_subscript::<Array<_>, Nullable<Integer>, _, _, _>("]
#[doc = "     vec![None::<i32>, Some(1), Some(2), Some(3)], None::<i32>, 2))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None::<i32>, pos);"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[allow(non_camel_case_types)]
pub fn array_position_with_subscript<Arr: ArrayOrNullableArray<Inner = E> +
    SingleValue, E: SingleValue, a, elem,
    subscript>(a: a, elem: elem, subscript: subscript)
    -> array_position_with_subscript<Arr, E, a, elem, subscript> where
    a: diesel::expression::AsExpression<Arr>,
    elem: diesel::expression::AsExpression<E>,
    subscript: diesel::expression::AsExpression<Integer> {
    array_position_with_subscript_utils::array_position_with_subscript {
        a: a.as_expression(),
        elem: elem.as_expression(),
        subscript: subscript.as_expression(),
        Arr: ::std::marker::PhantomData,
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`array_position_with_subscript()`](fn@array_position_with_subscript)"]
pub type array_position_with_subscript<Arr, E, a, elem, subscript> =
    array_position_with_subscript_utils::array_position_with_subscript<Arr, E,
    <a as diesel::expression::AsExpression<Arr>>::Expression,
    <elem as diesel::expression::AsExpression<E>>::Expression,
    <subscript as diesel::expression::AsExpression<Integer>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_position_with_subscript_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_position_with_subscript<Arr, E, a, elem, subscript> {
        pub(in super) a: a,
        pub(in super) elem: elem,
        pub(in super) subscript: subscript,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<Arr, E, a, elem, subscript, __Rhs> ::std::ops::Add<__Rhs> for
                array_position_with_subscript<Arr, E, a, elem, subscript>
                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<Arr, E, a, elem, subscript, __Rhs> ::std::ops::Sub<__Rhs> for
                array_position_with_subscript<Arr, E, a, elem, subscript>
                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<Arr, E, a, elem, subscript, __Rhs> ::std::ops::Mul<__Rhs> for
                array_position_with_subscript<Arr, E, a, elem, subscript>
                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<Arr, E, a, elem, subscript, __Rhs> ::std::ops::Div<__Rhs> for
                array_position_with_subscript<Arr, E, a, elem, subscript>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, E: ::core::fmt::Debug,
        a: ::core::fmt::Debug, elem: ::core::fmt::Debug,
        subscript: ::core::fmt::Debug> ::core::fmt::Debug for
        array_position_with_subscript<Arr, E, a, elem, subscript> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field5_finish(f,
                "array_position_with_subscript", "a", &self.a, "elem",
                &self.elem, "subscript", &self.subscript, "Arr", &self.Arr,
                "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, E: ::core::clone::Clone,
        a: ::core::clone::Clone, elem: ::core::clone::Clone,
        subscript: ::core::clone::Clone> ::core::clone::Clone for
        array_position_with_subscript<Arr, E, a, elem, subscript> {
        #[inline]
        fn clone(&self)
            -> array_position_with_subscript<Arr, E, a, elem, subscript> {
            array_position_with_subscript {
                a: ::core::clone::Clone::clone(&self.a),
                elem: ::core::clone::Clone::clone(&self.elem),
                subscript: ::core::clone::Clone::clone(&self.subscript),
                Arr: ::core::clone::Clone::clone(&self.Arr),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, E: ::core::marker::Copy,
        a: ::core::marker::Copy, elem: ::core::marker::Copy,
        subscript: ::core::marker::Copy> ::core::marker::Copy for
        array_position_with_subscript<Arr, E, a, elem, subscript> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                E: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                elem: diesel::query_builder::QueryId,
                subscript: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_position_with_subscript<Arr, E, a, elem, subscript> {
                type QueryId =
                    array_position_with_subscript<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <E as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <elem as diesel::query_builder::QueryId>::QueryId,
                    <subscript as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                        &&
                                        <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <elem as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <subscript as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                        || <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <elem as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <subscript as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`array_position_with_subscript()`](fn@array_position_with_subscript)"]
    pub type HelperType<Arr, E, a, elem, subscript> =
        array_position_with_subscript<Arr, E,
        <a as AsExpression<Arr>>::Expression,
        <elem as AsExpression<E>>::Expression,
        <subscript as AsExpression<Integer>>::Expression>;
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, subscript> Expression for
        array_position_with_subscript<Arr, E, a, elem, subscript> where
        (a, elem, subscript): Expression {
        type SqlType = Nullable<Integer>;
    }
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, subscript, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        array_position_with_subscript<Arr, E, a, elem, subscript> where
        a: SelectableExpression<__DieselInternal>,
        elem: SelectableExpression<__DieselInternal>,
        subscript: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, subscript, __DieselInternal> AppearsOnTable<__DieselInternal>
        for array_position_with_subscript<Arr, E, a, elem, subscript> where
        a: AppearsOnTable<__DieselInternal>,
        elem: AppearsOnTable<__DieselInternal>,
        subscript: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, subscript, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        array_position_with_subscript<Arr, E, a, elem, subscript> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>,
        elem: QueryFragment<__DieselInternal>,
        subscript: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_position";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.elem.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.elem.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.subscript.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.subscript.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, subscript> QueryFragment<crate::pg::Pg> for
        array_position_with_subscript<Arr, E, a, elem, subscript> where
        a: QueryFragment<crate::pg::Pg>, elem: QueryFragment<crate::pg::Pg>,
        subscript: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, elem, subscript>(a, elem, subscript);
    const _: () =
        {
            use diesel;
            impl<a, elem, subscript, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, elem, subscript> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                elem: diesel::expression::ValidGrouping<__GroupByClause>,
                subscript: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<elem
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<elem as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<subscript
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<elem as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<subscript as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue,
        a, elem, subscript, __DieselInternal> ValidGrouping<__DieselInternal>
        for array_position_with_subscript<Arr, E, a, elem, subscript> where
        __Derived<a, elem, subscript>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, elem, subscript> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Returns an array of the subscripts of all occurrences of the second argument in the"]
#[doc = " array given as first argument."]
#[doc = ""]
#[doc =
" The array must be one-dimensional. Comparisons are done using IS NOT DISTINCT FROM semantics,"]
#[doc = " so it is possible to search for NULL."]
#[doc =
" NULL is returned only if the array is NULL; if the value is not found in the array, an empty array is returned."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main(){"]
#[doc = " #    run_test().unwrap();"]
#[doc = " # }"]
#[doc = " # fn run_test()->QueryResult<()>{"]
#[doc = " #   use diesel::dsl::array_positions;"]
#[doc = " #   use diesel::sql_types::{Nullable,Array,Integer};"]
#[doc = " #   let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_positions::<Array<_>, Integer, _, _>(vec![1, 1, 2, 1], 1))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![1,2,4], pos);"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_positions::<Array<_>, Integer, _, _>(vec![1, 2, 3, 4], 5))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(Vec::<i32>::new(), pos);"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_positions::<Array<_>, Nullable<Integer>, _, _>("]
#[doc =
"     vec![None::<i32>, Some(2), Some(3), None::<i32>], None::<i32>))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(vec![1,4], pos);"]
#[doc = ""]
#[doc =
" let pos = diesel::select(array_positions::<Nullable<Array<_>>, Integer, _, _>("]
#[doc = "     None::<Vec<i32>>, 1))"]
#[doc = "     .get_result::<Option<Vec<i32>>>(connection)?;"]
#[doc = " assert_eq!(None::<Vec<i32>>, pos);"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[allow(non_camel_case_types)]
pub fn array_positions<Arr: ArrayOrNullableArray<Inner = E> + SingleValue +
    MaybeNullableValue<Array<Integer>>, E: SingleValue, a,
    elem>(a: a, elem: elem) -> array_positions<Arr, E, a, elem> where
    a: diesel::expression::AsExpression<Arr>,
    elem: diesel::expression::AsExpression<E> {
    array_positions_utils::array_positions {
        a: a.as_expression(),
        elem: elem.as_expression(),
        Arr: ::std::marker::PhantomData,
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_positions()`](fn@array_positions)"]
pub type array_positions<Arr, E, a, elem> =
    array_positions_utils::array_positions<Arr, E,
    <a as diesel::expression::AsExpression<Arr>>::Expression,
    <elem as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_positions_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_positions<Arr, E, a, elem> {
        pub(in super) a: a,
        pub(in super) elem: elem,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<Arr, E, a, elem, __Rhs> ::std::ops::Add<__Rhs> for
                array_positions<Arr, E, a, elem> 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<Arr, E, a, elem, __Rhs> ::std::ops::Sub<__Rhs> for
                array_positions<Arr, E, a, elem> 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<Arr, E, a, elem, __Rhs> ::std::ops::Mul<__Rhs> for
                array_positions<Arr, E, a, elem> 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<Arr, E, a, elem, __Rhs> ::std::ops::Div<__Rhs> for
                array_positions<Arr, E, a, elem> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, E: ::core::fmt::Debug,
        a: ::core::fmt::Debug, elem: ::core::fmt::Debug> ::core::fmt::Debug
        for array_positions<Arr, E, a, elem> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "array_positions", "a", &self.a, "elem", &self.elem, "Arr",
                &self.Arr, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, E: ::core::clone::Clone,
        a: ::core::clone::Clone, elem: ::core::clone::Clone>
        ::core::clone::Clone for array_positions<Arr, E, a, elem> {
        #[inline]
        fn clone(&self) -> array_positions<Arr, E, a, elem> {
            array_positions {
                a: ::core::clone::Clone::clone(&self.a),
                elem: ::core::clone::Clone::clone(&self.elem),
                Arr: ::core::clone::Clone::clone(&self.Arr),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, E: ::core::marker::Copy,
        a: ::core::marker::Copy, elem: ::core::marker::Copy>
        ::core::marker::Copy for array_positions<Arr, E, a, elem> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                E: diesel::query_builder::QueryId,
                a: diesel::query_builder::QueryId,
                elem: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_positions<Arr, E, a, elem> {
                type QueryId =
                    array_positions<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <E as diesel::query_builder::QueryId>::QueryId,
                    <a as diesel::query_builder::QueryId>::QueryId,
                    <elem as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <a as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <elem as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    || <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                || <a as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <elem as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_positions()`](fn@array_positions)"]
    pub type HelperType<Arr, E, a, elem> =
        array_positions<Arr, E, <a as AsExpression<Arr>>::Expression,
        <elem as AsExpression<E>>::Expression>;
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue +
        MaybeNullableValue<Array<Integer>>, E: SingleValue, a, elem>
        Expression for array_positions<Arr, E, a, elem> where
        (a, elem): Expression {
        type SqlType = Arr::Out;
    }
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue +
        MaybeNullableValue<Array<Integer>>, E: SingleValue, a, elem,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        array_positions<Arr, E, a, elem> where
        a: SelectableExpression<__DieselInternal>,
        elem: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue +
        MaybeNullableValue<Array<Integer>>, E: SingleValue, a, elem,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_positions<Arr, E, a, elem> where
        a: AppearsOnTable<__DieselInternal>,
        elem: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue +
        MaybeNullableValue<Array<Integer>>, E: SingleValue, a, elem,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        array_positions<Arr, E, a, elem> where
        __DieselInternal: diesel::backend::Backend,
        a: QueryFragment<__DieselInternal>,
        elem: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_positions";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.a.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.a.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.elem.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.elem.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue +
        MaybeNullableValue<Array<Integer>>, E: SingleValue, a, elem>
        QueryFragment<crate::pg::Pg> for array_positions<Arr, E, a, elem>
        where a: QueryFragment<crate::pg::Pg>,
        elem: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<a, elem>(a, elem);
    const _: () =
        {
            use diesel;
            impl<a, elem, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<a, elem> where
                a: diesel::expression::ValidGrouping<__GroupByClause>,
                elem: diesel::expression::ValidGrouping<__GroupByClause>,
                <a as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<elem
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<a as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<elem as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray<Inner = E> + SingleValue +
        MaybeNullableValue<Array<Integer>>, E: SingleValue, a, elem,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        array_positions<Arr, E, a, elem> where
        __Derived<a, elem>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<a, elem> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the number of dimensions of the array"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_ndims;"]
#[doc = " #     use diesel::sql_types::{Nullable, Array, Integer};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " // diesel currently only supports 1D arrays"]
#[doc =
" let dims = diesel::select(array_ndims::<Array<Integer>, _>(vec![1, 2]))"]
#[doc = "     .get_result::<i32>(connection)?;"]
#[doc = " assert_eq!(1, dims);"]
#[doc = ""]
#[doc =
" let dims = diesel::select(array_ndims::<Nullable<Array<Integer>>, _>(None::<Vec<i32>>))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, dims);"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_ndims<Arr: ArrayOrNullableArray + SingleValue +
    MaybeNullableValue<Integer>, arr>(arr: arr) -> array_ndims<Arr, arr> where
    arr: diesel::expression::AsExpression<Arr> {
    array_ndims_utils::array_ndims {
        arr: arr.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_ndims()`](fn@array_ndims)"]
pub type array_ndims<Arr, arr> =
    array_ndims_utils::array_ndims<Arr,
    <arr as diesel::expression::AsExpression<Arr>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_ndims_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_ndims<Arr, arr> {
        pub(in super) arr: arr,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, arr, __Rhs> ::std::ops::Add<__Rhs> for
                array_ndims<Arr, arr> 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<Arr, arr, __Rhs> ::std::ops::Sub<__Rhs> for
                array_ndims<Arr, arr> 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<Arr, arr, __Rhs> ::std::ops::Mul<__Rhs> for
                array_ndims<Arr, arr> 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<Arr, arr, __Rhs> ::std::ops::Div<__Rhs> for
                array_ndims<Arr, arr> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, arr: ::core::fmt::Debug> ::core::fmt::Debug
        for array_ndims<Arr, arr> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "array_ndims", "arr", &self.arr, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, arr: ::core::clone::Clone>
        ::core::clone::Clone for array_ndims<Arr, arr> {
        #[inline]
        fn clone(&self) -> array_ndims<Arr, arr> {
            array_ndims {
                arr: ::core::clone::Clone::clone(&self.arr),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, arr: ::core::marker::Copy>
        ::core::marker::Copy for array_ndims<Arr, arr> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                arr: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_ndims<Arr, arr> {
                type QueryId =
                    array_ndims<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <arr as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`array_ndims()`](fn@array_ndims)"]
    pub type HelperType<Arr, arr> =
        array_ndims<Arr, <arr as AsExpression<Arr>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, arr> Expression for array_ndims<Arr, arr>
        where (arr): Expression {
        type SqlType = Arr::Out;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, arr, __DieselInternal>
        SelectableExpression<__DieselInternal> for array_ndims<Arr, arr> where
        arr: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, arr, __DieselInternal>
        AppearsOnTable<__DieselInternal> for array_ndims<Arr, arr> where
        arr: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, arr, __DieselInternal>
        FunctionFragment<__DieselInternal> for array_ndims<Arr, arr> where
        __DieselInternal: diesel::backend::Backend,
        arr: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_ndims";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.arr.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.arr.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, arr> QueryFragment<crate::pg::Pg> for
        array_ndims<Arr, arr> where arr: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<arr>(arr);
    const _: () =
        {
            use diesel;
            impl<arr, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<arr> where
                arr: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <arr as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue +
        MaybeNullableValue<Integer>, arr, __DieselInternal>
        ValidGrouping<__DieselInternal> for array_ndims<Arr, arr> where
        __Derived<arr>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<arr> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the upper bound of the requested array"]
#[doc = ""]
#[doc = " This function returns null for dimensions that do not exist"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_upper;"]
#[doc = " #     use diesel::sql_types::{Integer, Array};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let result = diesel::select(array_upper::<Array<Integer>, _, _>(vec![1, 2, 3], 1))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(Some(3), result);"]
#[doc = ""]
#[doc = " // the array has only one dimension"]
#[doc =
" let result = diesel::select(array_upper::<Array<Integer>, _, _>(vec![1, 2, 3], 2))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_upper<Arr: ArrayOrNullableArray + SingleValue, array,
    dimension>(array: array, dimension: dimension)
    -> array_upper<Arr, array, dimension> where
    array: diesel::expression::AsExpression<Arr>,
    dimension: diesel::expression::AsExpression<Integer> {
    array_upper_utils::array_upper {
        array: array.as_expression(),
        dimension: dimension.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_upper()`](fn@array_upper)"]
pub type array_upper<Arr, array, dimension> =
    array_upper_utils::array_upper<Arr,
    <array as diesel::expression::AsExpression<Arr>>::Expression,
    <dimension as diesel::expression::AsExpression<Integer>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_upper_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_upper<Arr, array, dimension> {
        pub(in super) array: array,
        pub(in super) dimension: dimension,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, array, dimension, __Rhs> ::std::ops::Add<__Rhs> for
                array_upper<Arr, array, dimension> 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<Arr, array, dimension, __Rhs> ::std::ops::Sub<__Rhs> for
                array_upper<Arr, array, dimension> 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<Arr, array, dimension, __Rhs> ::std::ops::Mul<__Rhs> for
                array_upper<Arr, array, dimension> 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<Arr, array, dimension, __Rhs> ::std::ops::Div<__Rhs> for
                array_upper<Arr, array, dimension> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, array: ::core::fmt::Debug,
        dimension: ::core::fmt::Debug> ::core::fmt::Debug for
        array_upper<Arr, array, dimension> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f,
                "array_upper", "array", &self.array, "dimension",
                &self.dimension, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, array: ::core::clone::Clone,
        dimension: ::core::clone::Clone> ::core::clone::Clone for
        array_upper<Arr, array, dimension> {
        #[inline]
        fn clone(&self) -> array_upper<Arr, array, dimension> {
            array_upper {
                array: ::core::clone::Clone::clone(&self.array),
                dimension: ::core::clone::Clone::clone(&self.dimension),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, array: ::core::marker::Copy,
        dimension: ::core::marker::Copy> ::core::marker::Copy for
        array_upper<Arr, array, dimension> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                array: diesel::query_builder::QueryId,
                dimension: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                array_upper<Arr, array, dimension> {
                type QueryId =
                    array_upper<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <array as diesel::query_builder::QueryId>::QueryId,
                    <dimension as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <array as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <dimension as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <array as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <dimension as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`array_upper()`](fn@array_upper)"]
    pub type HelperType<Arr, array, dimension> =
        array_upper<Arr, <array as AsExpression<Arr>>::Expression,
        <dimension as AsExpression<Integer>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension> Expression
        for array_upper<Arr, array, dimension> where
        (array, dimension): Expression {
        type SqlType = Nullable<Integer>;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        array_upper<Arr, array, dimension> where
        array: SelectableExpression<__DieselInternal>,
        dimension: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_upper<Arr, array, dimension> where
        array: AppearsOnTable<__DieselInternal>,
        dimension: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        array_upper<Arr, array, dimension> where
        __DieselInternal: diesel::backend::Backend,
        array: QueryFragment<__DieselInternal>,
        dimension: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_upper";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.dimension.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.dimension.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension>
        QueryFragment<crate::pg::Pg> for array_upper<Arr, array, dimension>
        where array: QueryFragment<crate::pg::Pg>,
        dimension: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<array, dimension>(array, dimension);
    const _: () =
        {
            use diesel;
            impl<array, dimension, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<array, dimension> where
                array: diesel::expression::ValidGrouping<__GroupByClause>,
                dimension: diesel::expression::ValidGrouping<__GroupByClause>,
                <array as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<dimension
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<dimension as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, array, dimension,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        array_upper<Arr, array, dimension> where
        __Derived<array, dimension>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<array, dimension> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Randomly shuffles the first dimension of the array."]
#[doc = ""]
#[doc = " # Example"]
#[doc = " ```rust,no_run"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_shuffle;"]
#[doc = " #     use diesel::sql_types::{Array, Integer};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let shuffled = diesel::select(array_shuffle::<Array<Integer>, _>(vec![1, 2, 3, 4, 5]))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(5, shuffled.len());"]
#[doc = " assert_eq!(shuffled.iter().sum::<i32>(), 15);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_shuffle<Arr: ArrayOrNullableArray + SingleValue,
    array>(array: array) -> array_shuffle<Arr, array> where
    array: diesel::expression::AsExpression<Arr> {
    array_shuffle_utils::array_shuffle {
        array: array.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_shuffle()`](fn@array_shuffle)"]
pub type array_shuffle<Arr, array> =
    array_shuffle_utils::array_shuffle<Arr,
    <array as diesel::expression::AsExpression<Arr>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_shuffle_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_shuffle<Arr, array> {
        pub(in super) array: array,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, array, __Rhs> ::std::ops::Add<__Rhs> for
                array_shuffle<Arr, array> 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<Arr, array, __Rhs> ::std::ops::Sub<__Rhs> for
                array_shuffle<Arr, array> 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<Arr, array, __Rhs> ::std::ops::Mul<__Rhs> for
                array_shuffle<Arr, array> 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<Arr, array, __Rhs> ::std::ops::Div<__Rhs> for
                array_shuffle<Arr, array> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, array: ::core::fmt::Debug>
        ::core::fmt::Debug for array_shuffle<Arr, array> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "array_shuffle", "array", &self.array, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, array: ::core::clone::Clone>
        ::core::clone::Clone for array_shuffle<Arr, array> {
        #[inline]
        fn clone(&self) -> array_shuffle<Arr, array> {
            array_shuffle {
                array: ::core::clone::Clone::clone(&self.array),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, array: ::core::marker::Copy>
        ::core::marker::Copy for array_shuffle<Arr, array> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                array: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_shuffle<Arr, array> {
                type QueryId =
                    array_shuffle<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <array as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <array as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <array as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`array_shuffle()`](fn@array_shuffle)"]
    pub type HelperType<Arr, array> =
        array_shuffle<Arr, <array as AsExpression<Arr>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, array> Expression for
        array_shuffle<Arr, array> where (array): Expression {
        type SqlType = Arr;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, __DieselInternal>
        SelectableExpression<__DieselInternal> for array_shuffle<Arr, array>
        where array: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, __DieselInternal>
        AppearsOnTable<__DieselInternal> for array_shuffle<Arr, array> where
        array: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, __DieselInternal>
        FunctionFragment<__DieselInternal> for array_shuffle<Arr, array> where
        __DieselInternal: diesel::backend::Backend,
        array: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_shuffle";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array>
        QueryFragment<crate::pg::Pg> for array_shuffle<Arr, array> where
        array: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<array>(array);
    const _: () =
        {
            use diesel;
            impl<array, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<array> where
                array: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, array, __DieselInternal>
        ValidGrouping<__DieselInternal> for array_shuffle<Arr, array> where
        __Derived<array>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<array> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns an array of n items randomly selected from array."]
#[doc = " n may not exceed the length of the array."]
#[doc = ""]
#[doc = " # Example"]
#[doc = " ```rust,no_run"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_sample;"]
#[doc = " #     use diesel::sql_types::{Array, Integer, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let vec = vec![1, 2, 3, 4, 5];"]
#[doc =
" let sampled = diesel::select(array_sample::<Array<Integer>, _, _>(vec.clone(), 3))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(3, sampled.len());"]
#[doc = " assert!(sampled.iter().all(|x| vec.contains(x)));"]
#[doc = ""]
#[doc = " let vec: Vec<i32> = Vec::new();"]
#[doc =
" let sampled = diesel::select(array_sample::<Array<Integer>, _, _>(vec, 0))"]
#[doc = "     .get_result::<Vec<i32>>(connection)?;"]
#[doc = " assert_eq!(0, sampled.len());"]
#[doc = ""]
#[doc =
" let sampled = diesel::select(array_sample::<Nullable<Array<Integer>>, _, _>("]
#[doc = "     None::<Vec<i32>>,"]
#[doc = "     1,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<Vec<i32>>>(connection)?;"]
#[doc = " assert!(sampled.is_none());"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_sample<Arr: ArrayOrNullableArray + SingleValue, array,
    n>(array: array, n: n) -> array_sample<Arr, array, n> where
    array: diesel::expression::AsExpression<Arr>,
    n: diesel::expression::AsExpression<Integer> {
    array_sample_utils::array_sample {
        array: array.as_expression(),
        n: n.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_sample()`](fn@array_sample)"]
pub type array_sample<Arr, array, n> =
    array_sample_utils::array_sample<Arr,
    <array as diesel::expression::AsExpression<Arr>>::Expression,
    <n as diesel::expression::AsExpression<Integer>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_sample_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_sample<Arr, array, n> {
        pub(in super) array: array,
        pub(in super) n: n,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, array, n, __Rhs> ::std::ops::Add<__Rhs> for
                array_sample<Arr, array, n> 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<Arr, array, n, __Rhs> ::std::ops::Sub<__Rhs> for
                array_sample<Arr, array, n> 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<Arr, array, n, __Rhs> ::std::ops::Mul<__Rhs> for
                array_sample<Arr, array, n> 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<Arr, array, n, __Rhs> ::std::ops::Div<__Rhs> for
                array_sample<Arr, array, n> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, array: ::core::fmt::Debug,
        n: ::core::fmt::Debug> ::core::fmt::Debug for
        array_sample<Arr, array, n> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field3_finish(f,
                "array_sample", "array", &self.array, "n", &self.n, "Arr",
                &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, array: ::core::clone::Clone,
        n: ::core::clone::Clone> ::core::clone::Clone for
        array_sample<Arr, array, n> {
        #[inline]
        fn clone(&self) -> array_sample<Arr, array, n> {
            array_sample {
                array: ::core::clone::Clone::clone(&self.array),
                n: ::core::clone::Clone::clone(&self.n),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, array: ::core::marker::Copy,
        n: ::core::marker::Copy> ::core::marker::Copy for
        array_sample<Arr, array, n> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                array: diesel::query_builder::QueryId,
                n: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_sample<Arr, array, n>
                {
                type QueryId =
                    array_sample<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <array as diesel::query_builder::QueryId>::QueryId,
                    <n as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <array as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <n as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <array as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <n as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`array_sample()`](fn@array_sample)"]
    pub type HelperType<Arr, array, n> =
        array_sample<Arr, <array as AsExpression<Arr>>::Expression,
        <n as AsExpression<Integer>>::Expression>;
    impl<Arr: ArrayOrNullableArray + SingleValue, array, n> Expression for
        array_sample<Arr, array, n> where (array, n): Expression {
        type SqlType = Arr;
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, n, __DieselInternal>
        SelectableExpression<__DieselInternal> for array_sample<Arr, array, n>
        where array: SelectableExpression<__DieselInternal>,
        n: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, n, __DieselInternal>
        AppearsOnTable<__DieselInternal> for array_sample<Arr, array, n> where
        array: AppearsOnTable<__DieselInternal>,
        n: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + SingleValue, array, n, __DieselInternal>
        FunctionFragment<__DieselInternal> for array_sample<Arr, array, n>
        where __DieselInternal: diesel::backend::Backend,
        array: QueryFragment<__DieselInternal>,
        n: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_sample";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.n.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.n.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + SingleValue, array, n>
        QueryFragment<crate::pg::Pg> for array_sample<Arr, array, n> where
        array: QueryFragment<crate::pg::Pg>, n: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<array, n>(array, n);
    const _: () =
        {
            use diesel;
            impl<array, n, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<array, n> where
                array: diesel::expression::ValidGrouping<__GroupByClause>,
                n: diesel::expression::ValidGrouping<__GroupByClause>,
                <array as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<n
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<n as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr: ArrayOrNullableArray + SingleValue, array, n, __DieselInternal>
        ValidGrouping<__DieselInternal> for array_sample<Arr, array, n> where
        __Derived<array, n>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<array, n> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Converts any Array to json."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::array_to_json;"]
#[doc = " #     use diesel::sql_types::{Array, Integer, Text, Nullable};"]
#[doc = " #     use serde_json::Value;"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let json = diesel::select(array_to_json::<Array<Integer>, _>(vec![1, 2, 3, 4, 5]))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = serde_json::json!([1, 2, 3, 4, 5]);"]
#[doc = " assert_eq!(expected, json);"]
#[doc = " let json = diesel::select(array_to_json::<Array<Text>, _>(vec!["]
#[doc = "     \"hello\", \"world\", \"John\", \"Doe\","]
#[doc = " ]))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc =
" let expected: Value = serde_json::json!([\"hello\", \"world\", \"John\", \"Doe\"]);"]
#[doc = " assert_eq!(expected, json);"]
#[doc = " let empty: Vec<String> = Vec::new();"]
#[doc =
" let json = diesel::select(array_to_json::<Array<Nullable<Text>>, _>(empty))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(serde_json::json!([]), json);"]
#[doc =
" let json = diesel::select(array_to_json::<Nullable<Array<Integer>>, _>("]
#[doc = "     None::<Vec<i32>>,"]
#[doc = " ))"]
#[doc = " .get_result::<Option<Value>>(connection)?;"]
#[doc = " assert_eq!(None, json);"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn array_to_json<Arr: ArrayOrNullableArray + MaybeNullableValue<Json>,
    array>(array: array) -> array_to_json<Arr, array> where
    array: diesel::expression::AsExpression<Arr> {
    array_to_json_utils::array_to_json {
        array: array.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`array_to_json()`](fn@array_to_json)"]
pub type array_to_json<Arr, array> =
    array_to_json_utils::array_to_json<Arr,
    <array as diesel::expression::AsExpression<Arr>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod array_to_json_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct array_to_json<Arr, array> {
        pub(in super) array: array,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, array, __Rhs> ::std::ops::Add<__Rhs> for
                array_to_json<Arr, array> 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<Arr, array, __Rhs> ::std::ops::Sub<__Rhs> for
                array_to_json<Arr, array> 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<Arr, array, __Rhs> ::std::ops::Mul<__Rhs> for
                array_to_json<Arr, array> 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<Arr, array, __Rhs> ::std::ops::Div<__Rhs> for
                array_to_json<Arr, array> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, array: ::core::fmt::Debug>
        ::core::fmt::Debug for array_to_json<Arr, array> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "array_to_json", "array", &self.array, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, array: ::core::clone::Clone>
        ::core::clone::Clone for array_to_json<Arr, array> {
        #[inline]
        fn clone(&self) -> array_to_json<Arr, array> {
            array_to_json {
                array: ::core::clone::Clone::clone(&self.array),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, array: ::core::marker::Copy>
        ::core::marker::Copy for array_to_json<Arr, array> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                array: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for array_to_json<Arr, array> {
                type QueryId =
                    array_to_json<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <array as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <array as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <array as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`array_to_json()`](fn@array_to_json)"]
    pub type HelperType<Arr, array> =
        array_to_json<Arr, <array as AsExpression<Arr>>::Expression>;
    impl<Arr: ArrayOrNullableArray + MaybeNullableValue<Json>, array>
        Expression for array_to_json<Arr, array> where (array): Expression {
        type SqlType = Arr::Out;
    }
    impl<Arr: ArrayOrNullableArray + MaybeNullableValue<Json>, array,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        array_to_json<Arr, array> where
        array: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: ArrayOrNullableArray + MaybeNullableValue<Json>, array,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        array_to_json<Arr, array> where
        array: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: ArrayOrNullableArray + MaybeNullableValue<Json>, array,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        array_to_json<Arr, array> where
        __DieselInternal: diesel::backend::Backend,
        array: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "array_to_json";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: ArrayOrNullableArray + MaybeNullableValue<Json>, array>
        QueryFragment<crate::pg::Pg> for array_to_json<Arr, array> where
        array: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<array>(array);
    const _: () =
        {
            use diesel;
            impl<array, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<array> where
                array: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<Arr: ArrayOrNullableArray + MaybeNullableValue<Json>, array,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        array_to_json<Arr, array> where
        __Derived<array>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<array> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Converts any SQL value to json"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::to_json;"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc =
" #     use diesel::sql_types::{Integer, Array, Json, Text, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let result = diesel::select(to_json::<Integer, _>(1)).get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!(1), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(to_json::<Array<Text>, _>(vec![\"abc\", \"xyz\"]))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!([\"abc\", \"xyz\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(to_json::<Array<Nullable<Text>>, _>(Vec::<String>::new()))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(to_json::<Nullable<Text>, _>(None::<String>))"]
#[doc = "     .get_result::<Option<Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn to_json<E: MaybeNullableValue<Json>, e>(e: e) -> to_json<E, e> where
    e: diesel::expression::AsExpression<E> {
    to_json_utils::to_json {
        e: e.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`to_json()`](fn@to_json)"]
pub type to_json<E, e> =
    to_json_utils::to_json<E,
    <e as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod to_json_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct to_json<E, e> {
        pub(in super) e: e,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, e, __Rhs> ::std::ops::Add<__Rhs> for to_json<E, e> 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<E, e, __Rhs> ::std::ops::Sub<__Rhs> for to_json<E, e> 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<E, e, __Rhs> ::std::ops::Mul<__Rhs> for to_json<E, e> 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<E, e, __Rhs> ::std::ops::Div<__Rhs> for to_json<E, e> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, e: ::core::fmt::Debug> ::core::fmt::Debug for
        to_json<E, e> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "to_json",
                "e", &self.e, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, e: ::core::clone::Clone>
        ::core::clone::Clone for to_json<E, e> {
        #[inline]
        fn clone(&self) -> to_json<E, e> {
            to_json {
                e: ::core::clone::Clone::clone(&self.e),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, e: ::core::marker::Copy>
        ::core::marker::Copy for to_json<E, e> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                e: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for to_json<E, e> {
                type QueryId =
                    to_json<<E as diesel::query_builder::QueryId>::QueryId,
                    <e as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <e as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <e as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`to_json()`](fn@to_json)"]
    pub type HelperType<E, e> =
        to_json<E, <e as AsExpression<E>>::Expression>;
    impl<E: MaybeNullableValue<Json>, e> Expression for to_json<E, e> where
        (e): Expression {
        type SqlType = E::Out;
    }
    impl<E: MaybeNullableValue<Json>, e, __DieselInternal>
        SelectableExpression<__DieselInternal> for to_json<E, e> where
        e: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: MaybeNullableValue<Json>, e, __DieselInternal>
        AppearsOnTable<__DieselInternal> for to_json<E, e> where
        e: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: MaybeNullableValue<Json>, e, __DieselInternal>
        FunctionFragment<__DieselInternal> for to_json<E, e> where
        __DieselInternal: diesel::backend::Backend,
        e: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "to_json";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.e.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.e.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: MaybeNullableValue<Json>, e> QueryFragment<crate::pg::Pg> for
        to_json<E, e> where e: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<e>(e);
    const _: () =
        {
            use diesel;
            impl<e, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<e> where
                e: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <e as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<E: MaybeNullableValue<Json>, e, __DieselInternal>
        ValidGrouping<__DieselInternal> for to_json<E, e> where
        __Derived<e>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<e> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Converts any SQL value to jsonb"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::to_jsonb;"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc =
" #     use diesel::sql_types::{Integer, Array, Jsonb, Text, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let result = diesel::select(to_jsonb::<Integer, _>(1)).get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!(1), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(to_jsonb::<Array<Text>, _>(vec![\"abc\", \"def\"]))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!([\"abc\", \"def\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(to_jsonb::<Array<Nullable<Text>>, _>(Vec::<String>::new()))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(to_jsonb::<Nullable<Text>, _>(None::<String>))"]
#[doc = "     .get_result::<Option<Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn to_jsonb<E: MaybeNullableValue<Jsonb>, e>(e: e) -> to_jsonb<E, e> where
    e: diesel::expression::AsExpression<E> {
    to_jsonb_utils::to_jsonb {
        e: e.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`to_jsonb()`](fn@to_jsonb)"]
pub type to_jsonb<E, e> =
    to_jsonb_utils::to_jsonb<E,
    <e as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod to_jsonb_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct to_jsonb<E, e> {
        pub(in super) e: e,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, e, __Rhs> ::std::ops::Add<__Rhs> for to_jsonb<E, e> 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<E, e, __Rhs> ::std::ops::Sub<__Rhs> for to_jsonb<E, e> 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<E, e, __Rhs> ::std::ops::Mul<__Rhs> for to_jsonb<E, e> 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<E, e, __Rhs> ::std::ops::Div<__Rhs> for to_jsonb<E, e> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, e: ::core::fmt::Debug> ::core::fmt::Debug for
        to_jsonb<E, e> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f, "to_jsonb",
                "e", &self.e, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, e: ::core::clone::Clone>
        ::core::clone::Clone for to_jsonb<E, e> {
        #[inline]
        fn clone(&self) -> to_jsonb<E, e> {
            to_jsonb {
                e: ::core::clone::Clone::clone(&self.e),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, e: ::core::marker::Copy>
        ::core::marker::Copy for to_jsonb<E, e> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                e: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for to_jsonb<E, e> {
                type QueryId =
                    to_jsonb<<E as diesel::query_builder::QueryId>::QueryId,
                    <e as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <e as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <e as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`to_jsonb()`](fn@to_jsonb)"]
    pub type HelperType<E, e> =
        to_jsonb<E, <e as AsExpression<E>>::Expression>;
    impl<E: MaybeNullableValue<Jsonb>, e> Expression for to_jsonb<E, e> where
        (e): Expression {
        type SqlType = E::Out;
    }
    impl<E: MaybeNullableValue<Jsonb>, e, __DieselInternal>
        SelectableExpression<__DieselInternal> for to_jsonb<E, e> where
        e: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: MaybeNullableValue<Jsonb>, e, __DieselInternal>
        AppearsOnTable<__DieselInternal> for to_jsonb<E, e> where
        e: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: MaybeNullableValue<Jsonb>, e, __DieselInternal>
        FunctionFragment<__DieselInternal> for to_jsonb<E, e> where
        __DieselInternal: diesel::backend::Backend,
        e: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "to_jsonb";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.e.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.e.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: MaybeNullableValue<Jsonb>, e> QueryFragment<crate::pg::Pg> for
        to_jsonb<E, e> where e: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<e>(e);
    const _: () =
        {
            use diesel;
            impl<e, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<e> where
                e: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <e as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<E: MaybeNullableValue<Jsonb>, e, __DieselInternal>
        ValidGrouping<__DieselInternal> for to_jsonb<E, e> where
        __Derived<e>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<e> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Builds a JSON object out of a text array. The array must have an even number of members,"]
#[doc = " in which case they are taken as alternating key/value pairs"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::json_object;"]
#[doc = " #     use diesel::sql_types::{Array, Json, Nullable, Text};"]
#[doc = " #     use serde_json::Value;"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let json = diesel::select(json_object::<Array<Text>,_>(vec![\"hello\",\"world\"]))"]
#[doc = "                 .get_result::<Value>(connection)?;"]
#[doc = " let expected:Value = serde_json::json!({\"hello\":\"world\"});"]
#[doc = " assert_eq!(expected,json);"]
#[doc = ""]
#[doc =
" let json = diesel::select(json_object::<Array<Text>,_>(vec![\"hello\",\"world\",\"John\",\"Doe\"]))"]
#[doc = "                 .get_result::<Value>(connection)?;"]
#[doc =
" let expected:Value = serde_json::json!({\"hello\":\"world\",\"John\":\"Doe\"});"]
#[doc = " assert_eq!(expected,json);"]
#[doc = ""]
#[doc =
" let json = diesel::select(json_object::<Array<Text>,_>(vec![\"hello\",\"world\",\"John\"]))"]
#[doc = "                 .get_result::<Value>(connection);"]
#[doc = " assert!(json.is_err());"]
#[doc = ""]
#[doc = " let empty:Vec<String> = Vec::new();"]
#[doc =
" let json = diesel::select(json_object::<Array<Nullable<Text>>,_>(empty))"]
#[doc = "                 .get_result::<Value>(connection);"]
#[doc = " assert!(json.is_err());"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_object<Arr: TextArrayOrNullableTextArray +
    MaybeNullableValue<Json>, text_array>(text_array: text_array)
    -> json_object<Arr, text_array> where
    text_array: diesel::expression::AsExpression<Arr> {
    json_object_utils::json_object {
        text_array: text_array.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_object()`](fn@json_object)"]
pub type json_object<Arr, text_array> =
    json_object_utils::json_object<Arr,
    <text_array as diesel::expression::AsExpression<Arr>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_object_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct json_object<Arr, text_array> {
        pub(in super) text_array: text_array,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, text_array, __Rhs> ::std::ops::Add<__Rhs> for
                json_object<Arr, text_array> 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<Arr, text_array, __Rhs> ::std::ops::Sub<__Rhs> for
                json_object<Arr, text_array> 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<Arr, text_array, __Rhs> ::std::ops::Mul<__Rhs> for
                json_object<Arr, text_array> 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<Arr, text_array, __Rhs> ::std::ops::Div<__Rhs> for
                json_object<Arr, text_array> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, text_array: ::core::fmt::Debug>
        ::core::fmt::Debug for json_object<Arr, text_array> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "json_object", "text_array", &self.text_array, "Arr",
                &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, text_array: ::core::clone::Clone>
        ::core::clone::Clone for json_object<Arr, text_array> {
        #[inline]
        fn clone(&self) -> json_object<Arr, text_array> {
            json_object {
                text_array: ::core::clone::Clone::clone(&self.text_array),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, text_array: ::core::marker::Copy>
        ::core::marker::Copy for json_object<Arr, text_array> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                text_array: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                json_object<Arr, text_array> {
                type QueryId =
                    json_object<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <text_array as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <text_array as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <text_array as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`json_object()`](fn@json_object)"]
    pub type HelperType<Arr, text_array> =
        json_object<Arr, <text_array as AsExpression<Arr>>::Expression>;
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Json>,
        text_array> Expression for json_object<Arr, text_array> where
        (text_array): Expression {
        type SqlType = Arr::Out;
    }
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Json>,
        text_array, __DieselInternal> SelectableExpression<__DieselInternal>
        for json_object<Arr, text_array> where
        text_array: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Json>,
        text_array, __DieselInternal> AppearsOnTable<__DieselInternal> for
        json_object<Arr, text_array> where
        text_array: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Json>,
        text_array, __DieselInternal> FunctionFragment<__DieselInternal> for
        json_object<Arr, text_array> where
        __DieselInternal: diesel::backend::Backend,
        text_array: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "json_object";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.text_array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.text_array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Json>,
        text_array> QueryFragment<crate::pg::Pg> for
        json_object<Arr, text_array> where
        text_array: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<text_array>(text_array);
    const _: () =
        {
            use diesel;
            impl<text_array, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<text_array> where
                text_array: diesel::expression::ValidGrouping<__GroupByClause>
                {
                type IsAggregate =
                    <text_array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Json>,
        text_array, __DieselInternal> ValidGrouping<__DieselInternal> for
        json_object<Arr, text_array> where
        __Derived<text_array>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<text_array> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" This form of json_object takes keys and values pairwise from two separate arrays."]
#[doc = " In all other respects it is identical to the one-argument form."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::json_object_with_keys_and_values;"]
#[doc = " #     use diesel::sql_types::{Array, Json, Nullable, Text};"]
#[doc = " #     use serde_json::Value;"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let json = diesel::select(json_object_with_keys_and_values::<Array<Text>, Array<Text>, _, _>("]
#[doc = "             vec![\"hello\",\"John\"],vec![\"world\",\"Doe\"]))"]
#[doc = "             .get_result::<Value>(connection)?;"]
#[doc =
" let expected:Value = serde_json::json!({\"hello\":\"world\",\"John\":\"Doe\"});"]
#[doc = " assert_eq!(expected,json);"]
#[doc = ""]
#[doc =
" let json = diesel::select(json_object_with_keys_and_values::<Nullable<Array<Text>>, Nullable<Array<Text>>, _, _>("]
#[doc = "             Some(vec![\"hello\",\"John\"]), None::<Vec<String>>))"]
#[doc = "             .get_result::<Option<Value>>(connection)?;"]
#[doc = " assert_eq!(None::<Value>,json);"]
#[doc = ""]
#[doc = " let empty: Vec<String> = Vec::new();"]
#[doc =
" let json = diesel::select(json_object_with_keys_and_values::<Array<Text>, Array<Text>, _, _>("]
#[doc = "             vec![\"hello\",\"John\"], empty))"]
#[doc = "             .get_result::<Value>(connection);"]
#[doc = " assert!(json.is_err());"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_object_with_keys_and_values<Arr1: TextArrayOrNullableTextArray +
    SingleValue, Arr2: TextArrayOrNullableTextArray +
    CombinedNullableValue<Arr1, Json>, keys,
    values>(keys: keys, values: values)
    -> json_object_with_keys_and_values<Arr1, Arr2, keys, values> where
    keys: diesel::expression::AsExpression<Arr1>,
    values: diesel::expression::AsExpression<Arr2> {
    json_object_with_keys_and_values_utils::json_object_with_keys_and_values {
        keys: keys.as_expression(),
        values: values.as_expression(),
        Arr1: ::std::marker::PhantomData,
        Arr2: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_object_with_keys_and_values()`](fn@json_object_with_keys_and_values)"]
pub type json_object_with_keys_and_values<Arr1, Arr2, keys, values> =
    json_object_with_keys_and_values_utils::json_object_with_keys_and_values<Arr1,
    Arr2, <keys as diesel::expression::AsExpression<Arr1>>::Expression,
    <values as diesel::expression::AsExpression<Arr2>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_object_with_keys_and_values_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct json_object_with_keys_and_values<Arr1, Arr2, keys, values> {
        pub(in super) keys: keys,
        pub(in super) values: values,
        pub(in super) Arr1: ::std::marker::PhantomData<Arr1>,
        pub(in super) Arr2: ::std::marker::PhantomData<Arr2>,
    }
    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<Arr1, Arr2, keys, values, __Rhs> ::std::ops::Add<__Rhs> for
                json_object_with_keys_and_values<Arr1, Arr2, keys, values>
                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<Arr1, Arr2, keys, values, __Rhs> ::std::ops::Sub<__Rhs> for
                json_object_with_keys_and_values<Arr1, Arr2, keys, values>
                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<Arr1, Arr2, keys, values, __Rhs> ::std::ops::Mul<__Rhs> for
                json_object_with_keys_and_values<Arr1, Arr2, keys, values>
                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<Arr1, Arr2, keys, values, __Rhs> ::std::ops::Div<__Rhs> for
                json_object_with_keys_and_values<Arr1, Arr2, keys, values>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr1: ::core::fmt::Debug, Arr2: ::core::fmt::Debug,
        keys: ::core::fmt::Debug, values: ::core::fmt::Debug>
        ::core::fmt::Debug for
        json_object_with_keys_and_values<Arr1, Arr2, keys, values> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "json_object_with_keys_and_values", "keys", &self.keys,
                "values", &self.values, "Arr1", &self.Arr1, "Arr2",
                &&self.Arr2)
        }
    }
    #[automatically_derived]
    impl<Arr1: ::core::clone::Clone, Arr2: ::core::clone::Clone,
        keys: ::core::clone::Clone, values: ::core::clone::Clone>
        ::core::clone::Clone for
        json_object_with_keys_and_values<Arr1, Arr2, keys, values> {
        #[inline]
        fn clone(&self)
            -> json_object_with_keys_and_values<Arr1, Arr2, keys, values> {
            json_object_with_keys_and_values {
                keys: ::core::clone::Clone::clone(&self.keys),
                values: ::core::clone::Clone::clone(&self.values),
                Arr1: ::core::clone::Clone::clone(&self.Arr1),
                Arr2: ::core::clone::Clone::clone(&self.Arr2),
            }
        }
    }
    #[automatically_derived]
    impl<Arr1: ::core::marker::Copy, Arr2: ::core::marker::Copy,
        keys: ::core::marker::Copy, values: ::core::marker::Copy>
        ::core::marker::Copy for
        json_object_with_keys_and_values<Arr1, Arr2, keys, values> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr1: diesel::query_builder::QueryId,
                Arr2: diesel::query_builder::QueryId,
                keys: diesel::query_builder::QueryId,
                values: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                json_object_with_keys_and_values<Arr1, Arr2, keys, values> {
                type QueryId =
                    json_object_with_keys_and_values<<Arr1 as
                    diesel::query_builder::QueryId>::QueryId,
                    <Arr2 as diesel::query_builder::QueryId>::QueryId,
                    <keys as diesel::query_builder::QueryId>::QueryId,
                    <values as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr1 as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                    <Arr2 as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <keys as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <values as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    ||
                                    <Arr2 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <keys as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <values as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`json_object_with_keys_and_values()`](fn@json_object_with_keys_and_values)"]
    pub type HelperType<Arr1, Arr2, keys, values> =
        json_object_with_keys_and_values<Arr1, Arr2,
        <keys as AsExpression<Arr1>>::Expression,
        <values as AsExpression<Arr2>>::Expression>;
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Json>, keys, values> Expression for
        json_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        (keys, values): Expression {
        type SqlType = Arr2::Out;
    }
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Json>, keys, values, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        json_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        keys: SelectableExpression<__DieselInternal>,
        values: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Json>, keys, values, __DieselInternal>
        AppearsOnTable<__DieselInternal> for
        json_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        keys: AppearsOnTable<__DieselInternal>,
        values: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Json>, keys, values, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        json_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        __DieselInternal: diesel::backend::Backend,
        keys: QueryFragment<__DieselInternal>,
        values: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "json_object";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.keys.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.keys.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.values.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.values.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Json>, keys, values>
        QueryFragment<crate::pg::Pg> for
        json_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        keys: QueryFragment<crate::pg::Pg>,
        values: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<keys, values>(keys, values);
    const _: () =
        {
            use diesel;
            impl<keys, values, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<keys, values> where
                keys: diesel::expression::ValidGrouping<__GroupByClause>,
                values: diesel::expression::ValidGrouping<__GroupByClause>,
                <keys as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<values
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<keys as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<values as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Json>, keys, values, __DieselInternal>
        ValidGrouping<__DieselInternal> for
        json_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        __Derived<keys, values>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<keys, values> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the type of the top-level json value as a text-string"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::json_typeof;"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc = " #     use diesel::sql_types::{Json, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let result = diesel::select(json_typeof::<Json, _>(json!({\"a\": \"b\", \"c\": 1})))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"object\".to_string(), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_typeof::<Json, _>(json!([1,2,3])))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"array\".to_string(), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_typeof::<Json, _>(json!(\"abc\")))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"string\".to_string(), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_typeof::<Json, _>(json!(-123.4)))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"number\".to_string(), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_typeof::<Json, _>(json!(true)))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"boolean\".to_string(), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_typeof::<Json, _>(json!(null)))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"null\".to_string(), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_typeof::<Nullable<Json>, _>(None::<Value>))"]
#[doc = "     .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_typeof<E: JsonOrNullableJson + SingleValue +
    MaybeNullableValue<Text>, e>(e: e) -> json_typeof<E, e> where
    e: diesel::expression::AsExpression<E> {
    json_typeof_utils::json_typeof {
        e: e.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_typeof()`](fn@json_typeof)"]
pub type json_typeof<E, e> =
    json_typeof_utils::json_typeof<E,
    <e as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_typeof_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct json_typeof<E, e> {
        pub(in super) e: e,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, e, __Rhs> ::std::ops::Add<__Rhs> for json_typeof<E, e>
                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<E, e, __Rhs> ::std::ops::Sub<__Rhs> for json_typeof<E, e>
                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<E, e, __Rhs> ::std::ops::Mul<__Rhs> for json_typeof<E, e>
                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<E, e, __Rhs> ::std::ops::Div<__Rhs> for json_typeof<E, e>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, e: ::core::fmt::Debug> ::core::fmt::Debug for
        json_typeof<E, e> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "json_typeof", "e", &self.e, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, e: ::core::clone::Clone>
        ::core::clone::Clone for json_typeof<E, e> {
        #[inline]
        fn clone(&self) -> json_typeof<E, e> {
            json_typeof {
                e: ::core::clone::Clone::clone(&self.e),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, e: ::core::marker::Copy>
        ::core::marker::Copy for json_typeof<E, e> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                e: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for json_typeof<E, e> {
                type QueryId =
                    json_typeof<<E as diesel::query_builder::QueryId>::QueryId,
                    <e as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <e as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <e as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`json_typeof()`](fn@json_typeof)"]
    pub type HelperType<E, e> =
        json_typeof<E, <e as AsExpression<E>>::Expression>;
    impl<E: JsonOrNullableJson + SingleValue + MaybeNullableValue<Text>, e>
        Expression for json_typeof<E, e> where (e): Expression {
        type SqlType = E::Out;
    }
    impl<E: JsonOrNullableJson + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        json_typeof<E, e> where e: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonOrNullableJson + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        json_typeof<E, e> where e: AppearsOnTable<__DieselInternal>,
        Self: Expression {}
    impl<E: JsonOrNullableJson + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        json_typeof<E, e> where __DieselInternal: diesel::backend::Backend,
        e: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "json_typeof";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.e.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.e.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonOrNullableJson + SingleValue + MaybeNullableValue<Text>, e>
        QueryFragment<crate::pg::Pg> for json_typeof<E, e> where
        e: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<e>(e);
    const _: () =
        {
            use diesel;
            impl<e, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<e> where
                e: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <e as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<E: JsonOrNullableJson + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        json_typeof<E, e> where __Derived<e>: ValidGrouping<__DieselInternal>
        {
        type IsAggregate =
            <__Derived<e> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the type of the top-level jsonb value as a text-string"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_typeof;"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc = " #     use diesel::sql_types::{Jsonb, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!({\"a\": \"b\", \"c\": 1})))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"object\".to_string(), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!([1,2,3])))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"array\".to_string(), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!(\"abc\")))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"string\".to_string(), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!(-123.4)))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"number\".to_string(), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!(true)))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"boolean\".to_string(), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!(null)))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"null\".to_string(), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_typeof::<Nullable<Jsonb>, _>(None::<Value>))"]
#[doc = "     .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_typeof<E: JsonbOrNullableJsonb + SingleValue +
    MaybeNullableValue<Text>, e>(e: e) -> jsonb_typeof<E, e> where
    e: diesel::expression::AsExpression<E> {
    jsonb_typeof_utils::jsonb_typeof {
        e: e.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_typeof()`](fn@jsonb_typeof)"]
pub type jsonb_typeof<E, e> =
    jsonb_typeof_utils::jsonb_typeof<E,
    <e as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_typeof_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_typeof<E, e> {
        pub(in super) e: e,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, e, __Rhs> ::std::ops::Add<__Rhs> for jsonb_typeof<E, e>
                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<E, e, __Rhs> ::std::ops::Sub<__Rhs> for jsonb_typeof<E, e>
                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<E, e, __Rhs> ::std::ops::Mul<__Rhs> for jsonb_typeof<E, e>
                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<E, e, __Rhs> ::std::ops::Div<__Rhs> for jsonb_typeof<E, e>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, e: ::core::fmt::Debug> ::core::fmt::Debug for
        jsonb_typeof<E, e> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "jsonb_typeof", "e", &self.e, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, e: ::core::clone::Clone>
        ::core::clone::Clone for jsonb_typeof<E, e> {
        #[inline]
        fn clone(&self) -> jsonb_typeof<E, e> {
            jsonb_typeof {
                e: ::core::clone::Clone::clone(&self.e),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, e: ::core::marker::Copy>
        ::core::marker::Copy for jsonb_typeof<E, e> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                e: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for jsonb_typeof<E, e> {
                type QueryId =
                    jsonb_typeof<<E as diesel::query_builder::QueryId>::QueryId,
                    <e as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <e as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <e as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`jsonb_typeof()`](fn@jsonb_typeof)"]
    pub type HelperType<E, e> =
        jsonb_typeof<E, <e as AsExpression<E>>::Expression>;
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e>
        Expression for jsonb_typeof<E, e> where (e): Expression {
        type SqlType = E::Out;
    }
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        jsonb_typeof<E, e> where e: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        jsonb_typeof<E, e> where e: AppearsOnTable<__DieselInternal>,
        Self: Expression {}
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        jsonb_typeof<E, e> where __DieselInternal: diesel::backend::Backend,
        e: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_typeof";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.e.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.e.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e>
        QueryFragment<crate::pg::Pg> for jsonb_typeof<E, e> where
        e: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<e>(e);
    const _: () =
        {
            use diesel;
            impl<e, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<e> where
                e: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <e as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        jsonb_typeof<E, e> where __Derived<e>: ValidGrouping<__DieselInternal>
        {
        type IsAggregate =
            <__Derived<e> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Converts the given json value to pretty-printed, indented text"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_pretty;"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc = " #     use diesel::sql_types::{Jsonb, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!([{\"f1\":1,\"f2\":null},2,null,3])))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"["]
#[doc = "     {"]
#[doc = "         \"f1\": 1,"]
#[doc = "         \"f2\": null"]
#[doc = "     },"]
#[doc = "     2,"]
#[doc = "     null,"]
#[doc = "     3"]
#[doc = " ]\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!({\"a\": 1, \"b\": \"cd\"})))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"{"]
#[doc = "     \"a\": 1,"]
#[doc = "     \"b\": \"cd\""]
#[doc = " }\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!(\"abc\")))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"\"abc\"\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!(22)))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"22\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!(false)))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"false\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!(null)))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"null\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!({})))"]
#[doc = "     .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"{"]
#[doc = " }\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_pretty::<Nullable<Jsonb>, _>(None::<Value>))"]
#[doc = "     .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_pretty<E: JsonbOrNullableJsonb + SingleValue +
    MaybeNullableValue<Text>, e>(e: e) -> jsonb_pretty<E, e> where
    e: diesel::expression::AsExpression<E> {
    jsonb_pretty_utils::jsonb_pretty {
        e: e.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_pretty()`](fn@jsonb_pretty)"]
pub type jsonb_pretty<E, e> =
    jsonb_pretty_utils::jsonb_pretty<E,
    <e as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_pretty_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_pretty<E, e> {
        pub(in super) e: e,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, e, __Rhs> ::std::ops::Add<__Rhs> for jsonb_pretty<E, e>
                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<E, e, __Rhs> ::std::ops::Sub<__Rhs> for jsonb_pretty<E, e>
                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<E, e, __Rhs> ::std::ops::Mul<__Rhs> for jsonb_pretty<E, e>
                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<E, e, __Rhs> ::std::ops::Div<__Rhs> for jsonb_pretty<E, e>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, e: ::core::fmt::Debug> ::core::fmt::Debug for
        jsonb_pretty<E, e> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "jsonb_pretty", "e", &self.e, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, e: ::core::clone::Clone>
        ::core::clone::Clone for jsonb_pretty<E, e> {
        #[inline]
        fn clone(&self) -> jsonb_pretty<E, e> {
            jsonb_pretty {
                e: ::core::clone::Clone::clone(&self.e),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, e: ::core::marker::Copy>
        ::core::marker::Copy for jsonb_pretty<E, e> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                e: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for jsonb_pretty<E, e> {
                type QueryId =
                    jsonb_pretty<<E as diesel::query_builder::QueryId>::QueryId,
                    <e as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <e as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        && true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <e as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`jsonb_pretty()`](fn@jsonb_pretty)"]
    pub type HelperType<E, e> =
        jsonb_pretty<E, <e as AsExpression<E>>::Expression>;
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e>
        Expression for jsonb_pretty<E, e> where (e): Expression {
        type SqlType = E::Out;
    }
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        jsonb_pretty<E, e> where e: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        jsonb_pretty<E, e> where e: AppearsOnTable<__DieselInternal>,
        Self: Expression {}
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        jsonb_pretty<E, e> where __DieselInternal: diesel::backend::Backend,
        e: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_pretty";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.e.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.e.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e>
        QueryFragment<crate::pg::Pg> for jsonb_pretty<E, e> where
        e: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<e>(e);
    const _: () =
        {
            use diesel;
            impl<e, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<e> where
                e: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <e as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>, e,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        jsonb_pretty<E, e> where __Derived<e>: ValidGrouping<__DieselInternal>
        {
        type IsAggregate =
            <__Derived<e> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Deletes all object fields that have null values from the given JSON value, recursively."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::json_strip_nulls;"]
#[doc = " #     use diesel::sql_types::{Json, Nullable};"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_strip_nulls::<Json, _>(json!({\"hello\": null})))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = json!({});"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_strip_nulls::<Json, _>(json!([{\"f1\":1, \"f2\":null}, 2, null, 3])))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = json!([{\"f1\":1}, 2, null, 3]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_strip_nulls::<Nullable<Json>, _>(None::<Value>))"]
#[doc = "     .get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_strip_nulls::<Json, _>(json!(null)))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = " let expected = json!(null);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_strip_nulls<E: JsonOrNullableJson + SingleValue, json>(json: json)
    -> json_strip_nulls<E, json> where
    json: diesel::expression::AsExpression<E> {
    json_strip_nulls_utils::json_strip_nulls {
        json: json.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_strip_nulls()`](fn@json_strip_nulls)"]
pub type json_strip_nulls<E, json> =
    json_strip_nulls_utils::json_strip_nulls<E,
    <json as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_strip_nulls_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct json_strip_nulls<E, json> {
        pub(in super) json: json,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, json, __Rhs> ::std::ops::Add<__Rhs> for
                json_strip_nulls<E, json> 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<E, json, __Rhs> ::std::ops::Sub<__Rhs> for
                json_strip_nulls<E, json> 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<E, json, __Rhs> ::std::ops::Mul<__Rhs> for
                json_strip_nulls<E, json> 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<E, json, __Rhs> ::std::ops::Div<__Rhs> for
                json_strip_nulls<E, json> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, json: ::core::fmt::Debug> ::core::fmt::Debug
        for json_strip_nulls<E, json> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "json_strip_nulls", "json", &self.json, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, json: ::core::clone::Clone>
        ::core::clone::Clone for json_strip_nulls<E, json> {
        #[inline]
        fn clone(&self) -> json_strip_nulls<E, json> {
            json_strip_nulls {
                json: ::core::clone::Clone::clone(&self.json),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, json: ::core::marker::Copy>
        ::core::marker::Copy for json_strip_nulls<E, json> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                json: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for json_strip_nulls<E, json> {
                type QueryId =
                    json_strip_nulls<<E as
                    diesel::query_builder::QueryId>::QueryId,
                    <json as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <json as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc = "The return type of [`json_strip_nulls()`](fn@json_strip_nulls)"]
    pub type HelperType<E, json> =
        json_strip_nulls<E, <json as AsExpression<E>>::Expression>;
    impl<E: JsonOrNullableJson + SingleValue, json> Expression for
        json_strip_nulls<E, json> where (json): Expression {
        type SqlType = E;
    }
    impl<E: JsonOrNullableJson + SingleValue, json, __DieselInternal>
        SelectableExpression<__DieselInternal> for json_strip_nulls<E, json>
        where json: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonOrNullableJson + SingleValue, json, __DieselInternal>
        AppearsOnTable<__DieselInternal> for json_strip_nulls<E, json> where
        json: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: JsonOrNullableJson + SingleValue, json, __DieselInternal>
        FunctionFragment<__DieselInternal> for json_strip_nulls<E, json> where
        __DieselInternal: diesel::backend::Backend,
        json: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "json_strip_nulls";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.json.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.json.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonOrNullableJson + SingleValue, json>
        QueryFragment<crate::pg::Pg> for json_strip_nulls<E, json> where
        json: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<json>(json);
    const _: () =
        {
            use diesel;
            impl<json, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<json> where
                json: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <json as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<E: JsonOrNullableJson + SingleValue, json, __DieselInternal>
        ValidGrouping<__DieselInternal> for json_strip_nulls<E, json> where
        __Derived<json>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<json> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Deletes all object fields that have null values from the given JSON value, recursively."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_strip_nulls;"]
#[doc = " #     use diesel::sql_types::{Jsonb, Nullable};"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_strip_nulls::<Jsonb, _>(json!({\"hello\": null})))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = json!({});"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_strip_nulls::<Jsonb, _>(json!([{\"f1\":1, \"f2\":null}, 2, null, 3])))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = json!([{\"f1\":1}, 2, null, 3]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_strip_nulls::<Nullable<Jsonb>, _>(None::<Value>))"]
#[doc = "     .get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_strip_nulls::<Jsonb, _>(json!(null)))"]
#[doc = "     .get_result::<Value>(connection)?;"]
#[doc = " let expected = json!(null);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc = ""]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_strip_nulls<E: JsonbOrNullableJsonb + SingleValue,
    jsonb>(jsonb: jsonb) -> jsonb_strip_nulls<E, jsonb> where
    jsonb: diesel::expression::AsExpression<E> {
    jsonb_strip_nulls_utils::jsonb_strip_nulls {
        jsonb: jsonb.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_strip_nulls()`](fn@jsonb_strip_nulls)"]
pub type jsonb_strip_nulls<E, jsonb> =
    jsonb_strip_nulls_utils::jsonb_strip_nulls<E,
    <jsonb as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_strip_nulls_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_strip_nulls<E, jsonb> {
        pub(in super) jsonb: jsonb,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, jsonb, __Rhs> ::std::ops::Add<__Rhs> for
                jsonb_strip_nulls<E, jsonb> 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<E, jsonb, __Rhs> ::std::ops::Sub<__Rhs> for
                jsonb_strip_nulls<E, jsonb> 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<E, jsonb, __Rhs> ::std::ops::Mul<__Rhs> for
                jsonb_strip_nulls<E, jsonb> 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<E, jsonb, __Rhs> ::std::ops::Div<__Rhs> for
                jsonb_strip_nulls<E, jsonb> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, jsonb: ::core::fmt::Debug> ::core::fmt::Debug
        for jsonb_strip_nulls<E, jsonb> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "jsonb_strip_nulls", "jsonb", &self.jsonb, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, jsonb: ::core::clone::Clone>
        ::core::clone::Clone for jsonb_strip_nulls<E, jsonb> {
        #[inline]
        fn clone(&self) -> jsonb_strip_nulls<E, jsonb> {
            jsonb_strip_nulls {
                jsonb: ::core::clone::Clone::clone(&self.jsonb),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, jsonb: ::core::marker::Copy>
        ::core::marker::Copy for jsonb_strip_nulls<E, jsonb> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                jsonb: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for jsonb_strip_nulls<E, jsonb>
                {
                type QueryId =
                    jsonb_strip_nulls<<E as
                    diesel::query_builder::QueryId>::QueryId,
                    <jsonb as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <jsonb as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <jsonb as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`jsonb_strip_nulls()`](fn@jsonb_strip_nulls)"]
    pub type HelperType<E, jsonb> =
        jsonb_strip_nulls<E, <jsonb as AsExpression<E>>::Expression>;
    impl<E: JsonbOrNullableJsonb + SingleValue, jsonb> Expression for
        jsonb_strip_nulls<E, jsonb> where (jsonb): Expression {
        type SqlType = E;
    }
    impl<E: JsonbOrNullableJsonb + SingleValue, jsonb, __DieselInternal>
        SelectableExpression<__DieselInternal> for jsonb_strip_nulls<E, jsonb>
        where jsonb: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonbOrNullableJsonb + SingleValue, jsonb, __DieselInternal>
        AppearsOnTable<__DieselInternal> for jsonb_strip_nulls<E, jsonb> where
        jsonb: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: JsonbOrNullableJsonb + SingleValue, jsonb, __DieselInternal>
        FunctionFragment<__DieselInternal> for jsonb_strip_nulls<E, jsonb>
        where __DieselInternal: diesel::backend::Backend,
        jsonb: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_strip_nulls";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.jsonb.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.jsonb.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonbOrNullableJsonb + SingleValue, jsonb>
        QueryFragment<crate::pg::Pg> for jsonb_strip_nulls<E, jsonb> where
        jsonb: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<jsonb>(jsonb);
    const _: () =
        {
            use diesel;
            impl<jsonb, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<jsonb> where
                jsonb: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <jsonb as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<E: JsonbOrNullableJsonb + SingleValue, jsonb, __DieselInternal>
        ValidGrouping<__DieselInternal> for jsonb_strip_nulls<E, jsonb> where
        __Derived<jsonb>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<jsonb> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the number of elements in the top-level JSON array"]
#[doc = ""]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::json_array_length;"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc = " #     use diesel::sql_types::{Integer, Json, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length::<Json, _>(json!([1, 2, 3])))"]
#[doc = "     .get_result::<i32>(connection)?;"]
#[doc = " assert_eq!(result, 3);"]
#[doc = ""]
#[doc = " let result ="]
#[doc =
"     diesel::select(json_array_length::<Json, _>(json!([]))).get_result::<i32>(connection)?;"]
#[doc = " assert_eq!(result, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length::<Nullable<Json>, _>(None::<Value>))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_array_length<E: JsonOrNullableJson + MaybeNullableValue<Integer>,
    json>(json: json) -> json_array_length<E, json> where
    json: diesel::expression::AsExpression<E> {
    json_array_length_utils::json_array_length {
        json: json.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_array_length()`](fn@json_array_length)"]
pub type json_array_length<E, json> =
    json_array_length_utils::json_array_length<E,
    <json as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_array_length_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct json_array_length<E, json> {
        pub(in super) json: json,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, json, __Rhs> ::std::ops::Add<__Rhs> for
                json_array_length<E, json> 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<E, json, __Rhs> ::std::ops::Sub<__Rhs> for
                json_array_length<E, json> 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<E, json, __Rhs> ::std::ops::Mul<__Rhs> for
                json_array_length<E, json> 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<E, json, __Rhs> ::std::ops::Div<__Rhs> for
                json_array_length<E, json> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, json: ::core::fmt::Debug> ::core::fmt::Debug
        for json_array_length<E, json> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "json_array_length", "json", &self.json, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, json: ::core::clone::Clone>
        ::core::clone::Clone for json_array_length<E, json> {
        #[inline]
        fn clone(&self) -> json_array_length<E, json> {
            json_array_length {
                json: ::core::clone::Clone::clone(&self.json),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, json: ::core::marker::Copy>
        ::core::marker::Copy for json_array_length<E, json> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                json: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for json_array_length<E, json>
                {
                type QueryId =
                    json_array_length<<E as
                    diesel::query_builder::QueryId>::QueryId,
                    <json as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <json as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        || false;
            }
        };
    #[doc =
    "The return type of [`json_array_length()`](fn@json_array_length)"]
    pub type HelperType<E, json> =
        json_array_length<E, <json as AsExpression<E>>::Expression>;
    impl<E: JsonOrNullableJson + MaybeNullableValue<Integer>, json> Expression
        for json_array_length<E, json> where (json): Expression {
        type SqlType = E::Out;
    }
    impl<E: JsonOrNullableJson + MaybeNullableValue<Integer>, json,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        json_array_length<E, json> where
        json: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonOrNullableJson + MaybeNullableValue<Integer>, json,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        json_array_length<E, json> where
        json: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: JsonOrNullableJson + MaybeNullableValue<Integer>, json,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        json_array_length<E, json> where
        __DieselInternal: diesel::backend::Backend,
        json: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "json_array_length";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.json.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.json.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonOrNullableJson + MaybeNullableValue<Integer>, json>
        QueryFragment<crate::pg::Pg> for json_array_length<E, json> where
        json: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<json>(json);
    const _: () =
        {
            use diesel;
            impl<json, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<json> where
                json: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <json as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<E: JsonOrNullableJson + MaybeNullableValue<Integer>, json,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        json_array_length<E, json> where
        __Derived<json>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<json> as ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns the number of elements in the top-level JSON array"]
#[doc = ""]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_array_length;"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc = " #     use diesel::sql_types::{Integer, Jsonb, Nullable};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_array_length::<Jsonb, _>(json!([1, 2, 3])))"]
#[doc = "     .get_result::<i32>(connection)?;"]
#[doc = " assert_eq!(result, 3);"]
#[doc = ""]
#[doc = " let result ="]
#[doc =
"     diesel::select(jsonb_array_length::<Jsonb, _>(json!([]))).get_result::<i32>(connection)?;"]
#[doc = " assert_eq!(result, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_array_length::<Nullable<Jsonb>, _>(None::<Value>))"]
#[doc = "     .get_result::<Option<i32>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_array_length<E: JsonbOrNullableJsonb +
    MaybeNullableValue<Integer>, jsonb>(jsonb: jsonb)
    -> jsonb_array_length<E, jsonb> where
    jsonb: diesel::expression::AsExpression<E> {
    jsonb_array_length_utils::jsonb_array_length {
        jsonb: jsonb.as_expression(),
        E: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_array_length()`](fn@jsonb_array_length)"]
pub type jsonb_array_length<E, jsonb> =
    jsonb_array_length_utils::jsonb_array_length<E,
    <jsonb as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_array_length_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_array_length<E, jsonb> {
        pub(in super) jsonb: jsonb,
        pub(in super) E: ::std::marker::PhantomData<E>,
    }
    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<E, jsonb, __Rhs> ::std::ops::Add<__Rhs> for
                jsonb_array_length<E, jsonb> 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<E, jsonb, __Rhs> ::std::ops::Sub<__Rhs> for
                jsonb_array_length<E, jsonb> 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<E, jsonb, __Rhs> ::std::ops::Mul<__Rhs> for
                jsonb_array_length<E, jsonb> 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<E, jsonb, __Rhs> ::std::ops::Div<__Rhs> for
                jsonb_array_length<E, jsonb> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, jsonb: ::core::fmt::Debug> ::core::fmt::Debug
        for jsonb_array_length<E, jsonb> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "jsonb_array_length", "jsonb", &self.jsonb, "E", &&self.E)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, jsonb: ::core::clone::Clone>
        ::core::clone::Clone for jsonb_array_length<E, jsonb> {
        #[inline]
        fn clone(&self) -> jsonb_array_length<E, jsonb> {
            jsonb_array_length {
                jsonb: ::core::clone::Clone::clone(&self.jsonb),
                E: ::core::clone::Clone::clone(&self.E),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, jsonb: ::core::marker::Copy>
        ::core::marker::Copy for jsonb_array_length<E, jsonb> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                jsonb: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                jsonb_array_length<E, jsonb> {
                type QueryId =
                    jsonb_array_length<<E as
                    diesel::query_builder::QueryId>::QueryId,
                    <jsonb as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <jsonb as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <jsonb as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`jsonb_array_length()`](fn@jsonb_array_length)"]
    pub type HelperType<E, jsonb> =
        jsonb_array_length<E, <jsonb as AsExpression<E>>::Expression>;
    impl<E: JsonbOrNullableJsonb + MaybeNullableValue<Integer>, jsonb>
        Expression for jsonb_array_length<E, jsonb> where (jsonb): Expression
        {
        type SqlType = E::Out;
    }
    impl<E: JsonbOrNullableJsonb + MaybeNullableValue<Integer>, jsonb,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        jsonb_array_length<E, jsonb> where
        jsonb: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonbOrNullableJsonb + MaybeNullableValue<Integer>, jsonb,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        jsonb_array_length<E, jsonb> where
        jsonb: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: JsonbOrNullableJsonb + MaybeNullableValue<Integer>, jsonb,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        jsonb_array_length<E, jsonb> where
        __DieselInternal: diesel::backend::Backend,
        jsonb: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_array_length";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.jsonb.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.jsonb.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonbOrNullableJsonb + MaybeNullableValue<Integer>, jsonb>
        QueryFragment<crate::pg::Pg> for jsonb_array_length<E, jsonb> where
        jsonb: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<jsonb>(jsonb);
    const _: () =
        {
            use diesel;
            impl<jsonb, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<jsonb> where
                jsonb: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <jsonb as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<E: JsonbOrNullableJsonb + MaybeNullableValue<Integer>, jsonb,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        jsonb_array_length<E, jsonb> where
        __Derived<jsonb>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<jsonb> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Builds a JSON object out of a text array. The array must have an even number of members,"]
#[doc =
" in which case they are taken as alternating key/value pairs. This function also has a form that"]
#[doc = " that takes keys and values as separate text array arguments."]
#[doc =
" See [jsonb_object_with_keys_and_values](jsonb_object_with_keys_and_values())"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_object;"]
#[doc = " #     use diesel::sql_types::{Array, Json, Nullable, Text};"]
#[doc = " #     use serde_json::Value;"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let jsonb = diesel::select(jsonb_object::<Array<Text>,_>(vec![\"hello\",\"world\"]))"]
#[doc = "                 .get_result::<Value>(connection)?;"]
#[doc = " let expected:Value = serde_json::json!({\"hello\":\"world\"});"]
#[doc = " assert_eq!(expected, jsonb);"]
#[doc = ""]
#[doc =
" let jsonb = diesel::select(jsonb_object::<Array<Text>, _>(vec![\"hello\",\"world\",\"John\",\"Doe\"]))"]
#[doc = "                 .get_result::<Value>(connection)?;"]
#[doc =
" let expected:Value = serde_json::json!({\"hello\": \"world\",\"John\": \"Doe\"});"]
#[doc = " assert_eq!(expected, jsonb);"]
#[doc = ""]
#[doc =
" let jsonb = diesel::select(jsonb_object::<Nullable<Array<Text>>, _>(None::<Vec<String>>))"]
#[doc = "                 .get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(jsonb.is_none());"]
#[doc = ""]
#[doc = " let empty:Vec<String> = Vec::new();"]
#[doc =
" let jsonb = diesel::select(jsonb_object::<Array<Nullable<Text>>,_>(empty))"]
#[doc = "                 .get_result::<Value>(connection)?;"]
#[doc = " let expected = serde_json::json!({});"]
#[doc = " assert_eq!(expected, jsonb);"]
#[doc = ""]
#[doc =
" let jsonb = diesel::select(jsonb_object::<Array<Text>, _>(vec![\"hello\",\"world\",\"John\"]))"]
#[doc = "                 .get_result::<Value>(connection);"]
#[doc = " assert!(jsonb.is_err());"]
#[doc = ""]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_object<Arr: TextArrayOrNullableTextArray +
    MaybeNullableValue<Jsonb>, text_array>(text_array: text_array)
    -> jsonb_object<Arr, text_array> where
    text_array: diesel::expression::AsExpression<Arr> {
    jsonb_object_utils::jsonb_object {
        text_array: text_array.as_expression(),
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_object()`](fn@jsonb_object)"]
pub type jsonb_object<Arr, text_array> =
    jsonb_object_utils::jsonb_object<Arr,
    <text_array as diesel::expression::AsExpression<Arr>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_object_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_object<Arr, text_array> {
        pub(in super) text_array: text_array,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<Arr, text_array, __Rhs> ::std::ops::Add<__Rhs> for
                jsonb_object<Arr, text_array> 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<Arr, text_array, __Rhs> ::std::ops::Sub<__Rhs> for
                jsonb_object<Arr, text_array> 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<Arr, text_array, __Rhs> ::std::ops::Mul<__Rhs> for
                jsonb_object<Arr, text_array> 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<Arr, text_array, __Rhs> ::std::ops::Div<__Rhs> for
                jsonb_object<Arr, text_array> 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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr: ::core::fmt::Debug, text_array: ::core::fmt::Debug>
        ::core::fmt::Debug for jsonb_object<Arr, text_array> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "jsonb_object", "text_array", &self.text_array, "Arr",
                &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::clone::Clone, text_array: ::core::clone::Clone>
        ::core::clone::Clone for jsonb_object<Arr, text_array> {
        #[inline]
        fn clone(&self) -> jsonb_object<Arr, text_array> {
            jsonb_object {
                text_array: ::core::clone::Clone::clone(&self.text_array),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<Arr: ::core::marker::Copy, text_array: ::core::marker::Copy>
        ::core::marker::Copy for jsonb_object<Arr, text_array> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr: diesel::query_builder::QueryId,
                text_array: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                jsonb_object<Arr, text_array> {
                type QueryId =
                    jsonb_object<<Arr as
                    diesel::query_builder::QueryId>::QueryId,
                    <text_array as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <text_array as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <text_array as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`jsonb_object()`](fn@jsonb_object)"]
    pub type HelperType<Arr, text_array> =
        jsonb_object<Arr, <text_array as AsExpression<Arr>>::Expression>;
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Jsonb>,
        text_array> Expression for jsonb_object<Arr, text_array> where
        (text_array): Expression {
        type SqlType = Arr::Out;
    }
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Jsonb>,
        text_array, __DieselInternal> SelectableExpression<__DieselInternal>
        for jsonb_object<Arr, text_array> where
        text_array: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Jsonb>,
        text_array, __DieselInternal> AppearsOnTable<__DieselInternal> for
        jsonb_object<Arr, text_array> where
        text_array: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Jsonb>,
        text_array, __DieselInternal> FunctionFragment<__DieselInternal> for
        jsonb_object<Arr, text_array> where
        __DieselInternal: diesel::backend::Backend,
        text_array: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_object";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.text_array.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.text_array.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Jsonb>,
        text_array> QueryFragment<crate::pg::Pg> for
        jsonb_object<Arr, text_array> where
        text_array: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<text_array>(text_array);
    const _: () =
        {
            use diesel;
            impl<text_array, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<text_array> where
                text_array: diesel::expression::ValidGrouping<__GroupByClause>
                {
                type IsAggregate =
                    <text_array as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Jsonb>,
        text_array, __DieselInternal> ValidGrouping<__DieselInternal> for
        jsonb_object<Arr, text_array> where
        __Derived<text_array>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<text_array> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" This form of jsonb_object takes keys and values pairwise from two separate arrays."]
#[doc = " In all other respects it is identical to the one-argument form."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_object_with_keys_and_values;"]
#[doc = " #     use diesel::sql_types::{Array, Nullable, Text};"]
#[doc = " #     use serde_json::Value;"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc =
" let jsonb = diesel::select(jsonb_object_with_keys_and_values::<Array<Text>, Array<Text>, _, _>("]
#[doc = "             vec![\"hello\",\"John\"],vec![\"world\",\"Doe\"]))"]
#[doc = "             .get_result::<Value>(connection)?;"]
#[doc =
" let expected:Value = serde_json::json!({\"hello\":\"world\",\"John\":\"Doe\"});"]
#[doc = " assert_eq!(expected, jsonb);"]
#[doc = ""]
#[doc =
" let jsonb = diesel::select(jsonb_object_with_keys_and_values::<Nullable<Array<Text>>, Nullable<Array<Text>>, _, _>("]
#[doc = "             Some(vec![\"hello\",\"John\"]),None::<Vec<String>>))"]
#[doc = "             .get_result::<Option<Value>>(connection)?;"]
#[doc = " assert_eq!(None::<Value>,jsonb);"]
#[doc = ""]
#[doc = " let empty: Vec<String> = Vec::new();"]
#[doc =
" let jsonb = diesel::select(jsonb_object_with_keys_and_values::<Array<Text>, Array<Text>, _, _>("]
#[doc = "             vec![\"hello\",\"John\"],empty))"]
#[doc = "             .get_result::<Value>(connection);"]
#[doc = " assert!(jsonb.is_err());"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_object_with_keys_and_values<Arr1: TextArrayOrNullableTextArray +
    SingleValue, Arr2: TextArrayOrNullableTextArray +
    CombinedNullableValue<Arr1, Jsonb>, keys,
    values>(keys: keys, values: values)
    -> jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> where
    keys: diesel::expression::AsExpression<Arr1>,
    values: diesel::expression::AsExpression<Arr2> {
    jsonb_object_with_keys_and_values_utils::jsonb_object_with_keys_and_values {
        keys: keys.as_expression(),
        values: values.as_expression(),
        Arr1: ::std::marker::PhantomData,
        Arr2: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_object_with_keys_and_values()`](fn@jsonb_object_with_keys_and_values)"]
pub type jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> =
    jsonb_object_with_keys_and_values_utils::jsonb_object_with_keys_and_values<Arr1,
    Arr2, <keys as diesel::expression::AsExpression<Arr1>>::Expression,
    <values as diesel::expression::AsExpression<Arr2>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_object_with_keys_and_values_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> {
        pub(in super) keys: keys,
        pub(in super) values: values,
        pub(in super) Arr1: ::std::marker::PhantomData<Arr1>,
        pub(in super) Arr2: ::std::marker::PhantomData<Arr2>,
    }
    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<Arr1, Arr2, keys, values, __Rhs> ::std::ops::Add<__Rhs> for
                jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values>
                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<Arr1, Arr2, keys, values, __Rhs> ::std::ops::Sub<__Rhs> for
                jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values>
                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<Arr1, Arr2, keys, values, __Rhs> ::std::ops::Mul<__Rhs> for
                jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values>
                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<Arr1, Arr2, keys, values, __Rhs> ::std::ops::Div<__Rhs> for
                jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values>
                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())
                }
            }
        };
    #[automatically_derived]
    impl<Arr1: ::core::fmt::Debug, Arr2: ::core::fmt::Debug,
        keys: ::core::fmt::Debug, values: ::core::fmt::Debug>
        ::core::fmt::Debug for
        jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "jsonb_object_with_keys_and_values", "keys", &self.keys,
                "values", &self.values, "Arr1", &self.Arr1, "Arr2",
                &&self.Arr2)
        }
    }
    #[automatically_derived]
    impl<Arr1: ::core::clone::Clone, Arr2: ::core::clone::Clone,
        keys: ::core::clone::Clone, values: ::core::clone::Clone>
        ::core::clone::Clone for
        jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> {
        #[inline]
        fn clone(&self)
            -> jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> {
            jsonb_object_with_keys_and_values {
                keys: ::core::clone::Clone::clone(&self.keys),
                values: ::core::clone::Clone::clone(&self.values),
                Arr1: ::core::clone::Clone::clone(&self.Arr1),
                Arr2: ::core::clone::Clone::clone(&self.Arr2),
            }
        }
    }
    #[automatically_derived]
    impl<Arr1: ::core::marker::Copy, Arr2: ::core::marker::Copy,
        keys: ::core::marker::Copy, values: ::core::marker::Copy>
        ::core::marker::Copy for
        jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<Arr1: diesel::query_builder::QueryId,
                Arr2: diesel::query_builder::QueryId,
                keys: diesel::query_builder::QueryId,
                values: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> {
                type QueryId =
                    jsonb_object_with_keys_and_values<<Arr1 as
                    diesel::query_builder::QueryId>::QueryId,
                    <Arr2 as diesel::query_builder::QueryId>::QueryId,
                    <keys as diesel::query_builder::QueryId>::QueryId,
                    <values as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <Arr1 as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                    <Arr2 as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <keys as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <values as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <Arr1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    ||
                                    <Arr2 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <keys as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <values as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`jsonb_object_with_keys_and_values()`](fn@jsonb_object_with_keys_and_values)"]
    pub type HelperType<Arr1, Arr2, keys, values> =
        jsonb_object_with_keys_and_values<Arr1, Arr2,
        <keys as AsExpression<Arr1>>::Expression,
        <values as AsExpression<Arr2>>::Expression>;
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Jsonb>, keys, values> Expression for
        jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        (keys, values): Expression {
        type SqlType = Arr2::Out;
    }
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Jsonb>, keys, values, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        keys: SelectableExpression<__DieselInternal>,
        values: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Jsonb>, keys, values, __DieselInternal>
        AppearsOnTable<__DieselInternal> for
        jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        keys: AppearsOnTable<__DieselInternal>,
        values: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Jsonb>, keys, values, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        __DieselInternal: diesel::backend::Backend,
        keys: QueryFragment<__DieselInternal>,
        values: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_object";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.keys.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.keys.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.values.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.values.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Jsonb>, keys, values>
        QueryFragment<crate::pg::Pg> for
        jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        keys: QueryFragment<crate::pg::Pg>,
        values: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<keys, values>(keys, values);
    const _: () =
        {
            use diesel;
            impl<keys, values, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<keys, values> where
                keys: diesel::expression::ValidGrouping<__GroupByClause>,
                values: diesel::expression::ValidGrouping<__GroupByClause>,
                <keys as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<values
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<keys as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<values as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<Arr1: TextArrayOrNullableTextArray + SingleValue,
        Arr2: TextArrayOrNullableTextArray +
        CombinedNullableValue<Arr1, Jsonb>, keys, values, __DieselInternal>
        ValidGrouping<__DieselInternal> for
        jsonb_object_with_keys_and_values<Arr1, Arr2, keys, values> where
        __Derived<keys, values>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<keys, values> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" This function `row_to_json` takes a Record type as an input and converts it to JSON."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::row_to_json;"]
#[doc = " #     use diesel::dsl::sql;"]
#[doc = " #     use diesel::sql_types::{Record, Text, Integer};"]
#[doc = " #     use serde_json::Value;"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let json_value = diesel::select(row_to_json(sql::<Record<(Text, Integer)>>("]
#[doc = "     \"ROW(\'John\', 30)\""]
#[doc = " )))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = serde_json::json!({"]
#[doc = "     \"f1\": \"John\","]
#[doc = "     \"f2\": 30"]
#[doc = " });"]
#[doc = " assert_eq!(expected, json_value);"]
#[doc = ""]
#[doc =
" let json_value = diesel::select(row_to_json(sql::<Record<()>>(\"ROW()\")))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = serde_json::json!({});"]
#[doc = " assert_eq!(expected, json_value);"]
#[doc = ""]
#[doc = " #    Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn row_to_json<R: RecordOrNullableRecord + MaybeNullableValue<Json>,
    record>(record: record) -> row_to_json<R, record> where
    record: diesel::expression::AsExpression<R> {
    row_to_json_utils::row_to_json {
        record: record.as_expression(),
        R: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`row_to_json()`](fn@row_to_json)"]
pub type row_to_json<R, record> =
    row_to_json_utils::row_to_json<R,
    <record as diesel::expression::AsExpression<R>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod row_to_json_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct row_to_json<R, record> {
        pub(in super) record: record,
        pub(in super) R: ::std::marker::PhantomData<R>,
    }
    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<R, record, __Rhs> ::std::ops::Add<__Rhs> for
                row_to_json<R, record> 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<R, record, __Rhs> ::std::ops::Sub<__Rhs> for
                row_to_json<R, record> 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<R, record, __Rhs> ::std::ops::Mul<__Rhs> for
                row_to_json<R, record> 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<R, record, __Rhs> ::std::ops::Div<__Rhs> for
                row_to_json<R, record> 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())
                }
            }
        };
    #[automatically_derived]
    impl<R: ::core::fmt::Debug, record: ::core::fmt::Debug> ::core::fmt::Debug
        for row_to_json<R, record> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field2_finish(f,
                "row_to_json", "record", &self.record, "R", &&self.R)
        }
    }
    #[automatically_derived]
    impl<R: ::core::clone::Clone, record: ::core::clone::Clone>
        ::core::clone::Clone for row_to_json<R, record> {
        #[inline]
        fn clone(&self) -> row_to_json<R, record> {
            row_to_json {
                record: ::core::clone::Clone::clone(&self.record),
                R: ::core::clone::Clone::clone(&self.R),
            }
        }
    }
    #[automatically_derived]
    impl<R: ::core::marker::Copy, record: ::core::marker::Copy>
        ::core::marker::Copy for row_to_json<R, record> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<R: diesel::query_builder::QueryId,
                record: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for row_to_json<R, record> {
                type QueryId =
                    row_to_json<<R as diesel::query_builder::QueryId>::QueryId,
                    <record as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <R as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                            &&
                            <record as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <R as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <record as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`row_to_json()`](fn@row_to_json)"]
    pub type HelperType<R, record> =
        row_to_json<R, <record as AsExpression<R>>::Expression>;
    impl<R: RecordOrNullableRecord + MaybeNullableValue<Json>, record>
        Expression for row_to_json<R, record> where (record): Expression {
        type SqlType = R::Out;
    }
    impl<R: RecordOrNullableRecord + MaybeNullableValue<Json>, record,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        row_to_json<R, record> where
        record: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<R: RecordOrNullableRecord + MaybeNullableValue<Json>, record,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        row_to_json<R, record> where record: AppearsOnTable<__DieselInternal>,
        Self: Expression {}
    impl<R: RecordOrNullableRecord + MaybeNullableValue<Json>, record,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        row_to_json<R, record> where
        __DieselInternal: diesel::backend::Backend,
        record: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "row_to_json";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.record.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.record.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<R: RecordOrNullableRecord + MaybeNullableValue<Json>, record>
        QueryFragment<crate::pg::Pg> for row_to_json<R, record> where
        record: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<record>(record);
    const _: () =
        {
            use diesel;
            impl<record, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<record> where
                record: diesel::expression::ValidGrouping<__GroupByClause> {
                type IsAggregate =
                    <record as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
            }
        };
    impl<R: RecordOrNullableRecord + MaybeNullableValue<Json>, record,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        row_to_json<R, record> where
        __Derived<record>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<record> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" This function `json_populate_record` takes a Record base and Json as an input and converts it to top-level"]
#[doc =
" JSON object to a row having the composite type of the base argument."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::json_populate_record;"]
#[doc = " #     use diesel::dsl::sql;"]
#[doc = " #     use diesel::sql_types::{Record, Text, Integer, Json};"]
#[doc = " #     use serde_json::Value;"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let expected: Value = serde_json::json!({"]
#[doc = "     \"f1\": \"Alice\","]
#[doc = "     \"f2\": 16"]
#[doc = " });"]
#[doc =
" let record: (String, i32) = diesel::select(json_populate_record::<Record<(Text, Integer)>, Json, _, _>("]
#[doc = "         sql::<Record<(Text, Integer)>>(\"ROW(\'John\', 30)\"),"]
#[doc = "         expected"]
#[doc = " )).get_result(connection)?;"]
#[doc = " assert_eq!(record, (\"Alice\".to_string(), 16));"]
#[doc = ""]
#[doc = " let expected: Value = serde_json::json!({});"]
#[doc =
" let record: (String, i32) = diesel::select(json_populate_record::<Record<(Text, Integer)>, Json, _, _>("]
#[doc = "         sql::<Record<(Text, Integer)>>(\"ROW(\'John\', 30)\"),"]
#[doc = "         expected"]
#[doc = " )).get_result(connection)?;"]
#[doc = " assert_eq!(record, (\"John\".to_string(), 30));"]
#[doc = ""]
#[doc = " let expected: Value = serde_json::json!({"]
#[doc = "     \"f1\": \"Alice\""]
#[doc = " });"]
#[doc =
" let record: (String, i32) = diesel::select(json_populate_record::<Record<(Text, Integer)>, Json, _, _>("]
#[doc = "         sql::<Record<(Text, Integer)>>(\"ROW(\'John\', 30)\"),"]
#[doc = "         expected"]
#[doc = " )).get_result(connection)?;"]
#[doc = " assert_eq!(record, (\"Alice\".to_string(), 30));"]
#[doc = ""]
#[doc = " #    Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_populate_record<B: RecordOrNullableRecord + SingleValue,
    J: JsonOrNullableJson + CombinedAllNullableValue<Json, B>, base,
    from_json>(base: base, from_json: from_json)
    -> json_populate_record<B, J, base, from_json> where
    base: diesel::expression::AsExpression<B>,
    from_json: diesel::expression::AsExpression<J> {
    json_populate_record_utils::json_populate_record {
        base: base.as_expression(),
        from_json: from_json.as_expression(),
        B: ::std::marker::PhantomData,
        J: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_populate_record()`](fn@json_populate_record)"]
pub type json_populate_record<B, J, base, from_json> =
    json_populate_record_utils::json_populate_record<B, J,
    <base as diesel::expression::AsExpression<B>>::Expression,
    <from_json as diesel::expression::AsExpression<J>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_populate_record_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct json_populate_record<B, J, base, from_json> {
        pub(in super) base: base,
        pub(in super) from_json: from_json,
        pub(in super) B: ::std::marker::PhantomData<B>,
        pub(in super) J: ::std::marker::PhantomData<J>,
    }
    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<B, J, base, from_json, __Rhs> ::std::ops::Add<__Rhs> for
                json_populate_record<B, J, base, from_json> 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<B, J, base, from_json, __Rhs> ::std::ops::Sub<__Rhs> for
                json_populate_record<B, J, base, from_json> 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<B, J, base, from_json, __Rhs> ::std::ops::Mul<__Rhs> for
                json_populate_record<B, J, base, from_json> 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<B, J, base, from_json, __Rhs> ::std::ops::Div<__Rhs> for
                json_populate_record<B, J, base, from_json> 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())
                }
            }
        };
    #[automatically_derived]
    impl<B: ::core::fmt::Debug, J: ::core::fmt::Debug,
        base: ::core::fmt::Debug, from_json: ::core::fmt::Debug>
        ::core::fmt::Debug for json_populate_record<B, J, base, from_json> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "json_populate_record", "base", &self.base, "from_json",
                &self.from_json, "B", &self.B, "J", &&self.J)
        }
    }
    #[automatically_derived]
    impl<B: ::core::clone::Clone, J: ::core::clone::Clone,
        base: ::core::clone::Clone, from_json: ::core::clone::Clone>
        ::core::clone::Clone for json_populate_record<B, J, base, from_json> {
        #[inline]
        fn clone(&self) -> json_populate_record<B, J, base, from_json> {
            json_populate_record {
                base: ::core::clone::Clone::clone(&self.base),
                from_json: ::core::clone::Clone::clone(&self.from_json),
                B: ::core::clone::Clone::clone(&self.B),
                J: ::core::clone::Clone::clone(&self.J),
            }
        }
    }
    #[automatically_derived]
    impl<B: ::core::marker::Copy, J: ::core::marker::Copy,
        base: ::core::marker::Copy, from_json: ::core::marker::Copy>
        ::core::marker::Copy for json_populate_record<B, J, base, from_json> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<B: diesel::query_builder::QueryId,
                J: diesel::query_builder::QueryId,
                base: diesel::query_builder::QueryId,
                from_json: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                json_populate_record<B, J, base, from_json> {
                type QueryId =
                    json_populate_record<<B as
                    diesel::query_builder::QueryId>::QueryId,
                    <J as diesel::query_builder::QueryId>::QueryId,
                    <base as diesel::query_builder::QueryId>::QueryId,
                    <from_json as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <B as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <base as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <from_json as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <B as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                    <J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <base as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <from_json as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`json_populate_record()`](fn@json_populate_record)"]
    pub type HelperType<B, J, base, from_json> =
        json_populate_record<B, J, <base as AsExpression<B>>::Expression,
        <from_json as AsExpression<J>>::Expression>;
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonOrNullableJson +
        CombinedAllNullableValue<Json, B>, base, from_json> Expression for
        json_populate_record<B, J, base, from_json> where
        (base, from_json): Expression {
        type SqlType = J::Out;
    }
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonOrNullableJson +
        CombinedAllNullableValue<Json, B>, base, from_json, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        json_populate_record<B, J, base, from_json> where
        base: SelectableExpression<__DieselInternal>,
        from_json: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonOrNullableJson +
        CombinedAllNullableValue<Json, B>, base, from_json, __DieselInternal>
        AppearsOnTable<__DieselInternal> for
        json_populate_record<B, J, base, from_json> where
        base: AppearsOnTable<__DieselInternal>,
        from_json: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonOrNullableJson +
        CombinedAllNullableValue<Json, B>, base, from_json, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        json_populate_record<B, J, base, from_json> where
        __DieselInternal: diesel::backend::Backend,
        base: QueryFragment<__DieselInternal>,
        from_json: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "json_populate_record";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.base.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.base.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.from_json.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.from_json.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonOrNullableJson +
        CombinedAllNullableValue<Json, B>, base, from_json>
        QueryFragment<crate::pg::Pg> for
        json_populate_record<B, J, base, from_json> where
        base: QueryFragment<crate::pg::Pg>,
        from_json: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<base, from_json>(base, from_json);
    const _: () =
        {
            use diesel;
            impl<base, from_json, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<base, from_json> where
                base: diesel::expression::ValidGrouping<__GroupByClause>,
                from_json: diesel::expression::ValidGrouping<__GroupByClause>,
                <base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<from_json
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<base as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<from_json as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonOrNullableJson +
        CombinedAllNullableValue<Json, B>, base, from_json, __DieselInternal>
        ValidGrouping<__DieselInternal> for
        json_populate_record<B, J, base, from_json> where
        __Derived<base, from_json>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<base, from_json> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" This function `jsonb_populate_record` takes a Record base and Jsonb as an input and converts it to top-level"]
#[doc =
" JSON object to a row having the composite type of the base argument."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_populate_record;"]
#[doc = " #     use diesel::dsl::sql;"]
#[doc = " #     use diesel::sql_types::{Record, Text, Integer, Jsonb};"]
#[doc = " #     use serde_json::Value;"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let expected: Value = serde_json::json!({"]
#[doc = "     \"f1\": \"Alice\","]
#[doc = "     \"f2\": 16"]
#[doc = " });"]
#[doc =
" let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>("]
#[doc = "         sql::<Record<(Text, Integer)>>(\"ROW(\'John\', 30)\"),"]
#[doc = "         expected"]
#[doc = " )).get_result(connection)?;"]
#[doc = " assert_eq!(record, (\"Alice\".to_string(), 16));"]
#[doc = ""]
#[doc = " let expected: Value = serde_json::json!({});"]
#[doc =
" let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>("]
#[doc = "         sql::<Record<(Text, Integer)>>(\"ROW(\'John\', 30)\"),"]
#[doc = "         expected"]
#[doc = " )).get_result(connection)?;"]
#[doc = " assert_eq!(record, (\"John\".to_string(), 30));"]
#[doc = ""]
#[doc = " let expected: Value = serde_json::json!({"]
#[doc = "     \"f2\": 42,"]
#[doc = " });"]
#[doc =
" let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>("]
#[doc = "         sql::<Record<(Text, Integer)>>(\"ROW(\'John\', 30)\"),"]
#[doc = "         expected"]
#[doc = " )).get_result(connection)?;"]
#[doc = " assert_eq!(record, (\"John\".to_string(), 42));"]
#[doc = ""]
#[doc = " #    Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_populate_record<B: RecordOrNullableRecord + SingleValue,
    J: JsonbOrNullableJsonb + CombinedAllNullableValue<Jsonb, B>, base,
    from_json>(base: base, from_json: from_json)
    -> jsonb_populate_record<B, J, base, from_json> where
    base: diesel::expression::AsExpression<B>,
    from_json: diesel::expression::AsExpression<J> {
    jsonb_populate_record_utils::jsonb_populate_record {
        base: base.as_expression(),
        from_json: from_json.as_expression(),
        B: ::std::marker::PhantomData,
        J: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_populate_record()`](fn@jsonb_populate_record)"]
pub type jsonb_populate_record<B, J, base, from_json> =
    jsonb_populate_record_utils::jsonb_populate_record<B, J,
    <base as diesel::expression::AsExpression<B>>::Expression,
    <from_json as diesel::expression::AsExpression<J>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_populate_record_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_populate_record<B, J, base, from_json> {
        pub(in super) base: base,
        pub(in super) from_json: from_json,
        pub(in super) B: ::std::marker::PhantomData<B>,
        pub(in super) J: ::std::marker::PhantomData<J>,
    }
    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<B, J, base, from_json, __Rhs> ::std::ops::Add<__Rhs> for
                jsonb_populate_record<B, J, base, from_json> 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<B, J, base, from_json, __Rhs> ::std::ops::Sub<__Rhs> for
                jsonb_populate_record<B, J, base, from_json> 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<B, J, base, from_json, __Rhs> ::std::ops::Mul<__Rhs> for
                jsonb_populate_record<B, J, base, from_json> 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<B, J, base, from_json, __Rhs> ::std::ops::Div<__Rhs> for
                jsonb_populate_record<B, J, base, from_json> 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())
                }
            }
        };
    #[automatically_derived]
    impl<B: ::core::fmt::Debug, J: ::core::fmt::Debug,
        base: ::core::fmt::Debug, from_json: ::core::fmt::Debug>
        ::core::fmt::Debug for jsonb_populate_record<B, J, base, from_json> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field4_finish(f,
                "jsonb_populate_record", "base", &self.base, "from_json",
                &self.from_json, "B", &self.B, "J", &&self.J)
        }
    }
    #[automatically_derived]
    impl<B: ::core::clone::Clone, J: ::core::clone::Clone,
        base: ::core::clone::Clone, from_json: ::core::clone::Clone>
        ::core::clone::Clone for jsonb_populate_record<B, J, base, from_json>
        {
        #[inline]
        fn clone(&self) -> jsonb_populate_record<B, J, base, from_json> {
            jsonb_populate_record {
                base: ::core::clone::Clone::clone(&self.base),
                from_json: ::core::clone::Clone::clone(&self.from_json),
                B: ::core::clone::Clone::clone(&self.B),
                J: ::core::clone::Clone::clone(&self.J),
            }
        }
    }
    #[automatically_derived]
    impl<B: ::core::marker::Copy, J: ::core::marker::Copy,
        base: ::core::marker::Copy, from_json: ::core::marker::Copy>
        ::core::marker::Copy for jsonb_populate_record<B, J, base, from_json>
        {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<B: diesel::query_builder::QueryId,
                J: diesel::query_builder::QueryId,
                base: diesel::query_builder::QueryId,
                from_json: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                jsonb_populate_record<B, J, base, from_json> {
                type QueryId =
                    jsonb_populate_record<<B as
                    diesel::query_builder::QueryId>::QueryId,
                    <J as diesel::query_builder::QueryId>::QueryId,
                    <base as diesel::query_builder::QueryId>::QueryId,
                    <from_json as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <B as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                &&
                                <base as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <from_json as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <B as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                    <J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <base as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <from_json as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`jsonb_populate_record()`](fn@jsonb_populate_record)"]
    pub type HelperType<B, J, base, from_json> =
        jsonb_populate_record<B, J, <base as AsExpression<B>>::Expression,
        <from_json as AsExpression<J>>::Expression>;
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonbOrNullableJsonb +
        CombinedAllNullableValue<Jsonb, B>, base, from_json> Expression for
        jsonb_populate_record<B, J, base, from_json> where
        (base, from_json): Expression {
        type SqlType = J::Out;
    }
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonbOrNullableJsonb +
        CombinedAllNullableValue<Jsonb, B>, base, from_json, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        jsonb_populate_record<B, J, base, from_json> where
        base: SelectableExpression<__DieselInternal>,
        from_json: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonbOrNullableJsonb +
        CombinedAllNullableValue<Jsonb, B>, base, from_json, __DieselInternal>
        AppearsOnTable<__DieselInternal> for
        jsonb_populate_record<B, J, base, from_json> where
        base: AppearsOnTable<__DieselInternal>,
        from_json: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonbOrNullableJsonb +
        CombinedAllNullableValue<Jsonb, B>, base, from_json, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        jsonb_populate_record<B, J, base, from_json> where
        __DieselInternal: diesel::backend::Backend,
        base: QueryFragment<__DieselInternal>,
        from_json: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_populate_record";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.base.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.base.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.from_json.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.from_json.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonbOrNullableJsonb +
        CombinedAllNullableValue<Jsonb, B>, base, from_json>
        QueryFragment<crate::pg::Pg> for
        jsonb_populate_record<B, J, base, from_json> where
        base: QueryFragment<crate::pg::Pg>,
        from_json: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<base, from_json>(base, from_json);
    const _: () =
        {
            use diesel;
            impl<base, from_json, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<base, from_json> where
                base: diesel::expression::ValidGrouping<__GroupByClause>,
                from_json: diesel::expression::ValidGrouping<__GroupByClause>,
                <base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<from_json
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<base as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<from_json as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<B: RecordOrNullableRecord + SingleValue, J: JsonbOrNullableJsonb +
        CombinedAllNullableValue<Jsonb, B>, base, from_json, __DieselInternal>
        ValidGrouping<__DieselInternal> for
        jsonb_populate_record<B, J, base, from_json> where
        __Derived<base, from_json>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<base, from_json> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Returns target with the item designated by path replaced by new_value,"]
#[doc =
"     or with new_value added and the item designated by path does not exist."]
#[doc = ""]
#[doc = " It can\'t set path in scalar"]
#[doc = ""]
#[doc =
" All earlier steps in the path must exist, or the target is returned unchanged."]
#[doc =
" As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays."]
#[doc = " If the last path step is an array index that is out of range,"]
#[doc =
"    the new value is added at the beginning of the array if the index is negative,"]
#[doc = "     or at the end of the array if it is positive."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_set;"]
#[doc = " #     use diesel::sql_types::{Jsonb,Array, Json, Nullable, Text};"]
#[doc = " #     use serde_json::{json,Value};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_set::<Jsonb, Array<Text>, _, _, _>("]
#[doc = "         json!([{\"f1\":1,\"f2\":null},2,null,3]),"]
#[doc = "         vec![\"0\",\"f1\"],"]
#[doc = "         json!([2,3,4])"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc =
" let expected: Value = json!([{\"f1\": [2, 3, 4], \"f2\": null}, 2, null, 3]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_set::<Jsonb, Array<Text>, _, _, _>("]
#[doc = "         json!([{\"odd\":[2,4,6,8]}]),"]
#[doc = "         // not vec![\"odd\"], cannot set path in scalar"]
#[doc = "         vec![\"0\",\"odd\"],"]
#[doc = "         json!([1,3,5,7])"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = json!([{\"odd\":[1,3,5,7]}]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc = " let empty:Vec<String> = Vec::new();"]
#[doc =
" let result = diesel::select(jsonb_set::<Nullable<Jsonb>, Array<Nullable<Text>>, _, _, _>("]
#[doc = "         None::<Value>,"]
#[doc = "         empty,"]
#[doc = "         None::<Value>"]
#[doc = "     )).get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " let empty:Vec<String> = Vec::new();"]
#[doc =
" let result = diesel::select(jsonb_set::<Jsonb, Array<Nullable<Text>>, _, _, _>("]
#[doc = "         // cannot be json!(null)"]
#[doc = "         json!([]),"]
#[doc = "         empty,"]
#[doc = "         json!(null)"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc = " let expected = json!([]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_set::<Jsonb, Nullable<Array<Nullable<Text>>>, _, _, _,>("]
#[doc = "         json!(null),"]
#[doc = "         None::<Vec<String>>,"]
#[doc = "         json!({\"foo\": 42})"]
#[doc = "     )).get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_set<E: JsonbOrNullableJsonb + SingleValue,
    Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>, base,
    path, new_value>(base: base, path: path, new_value: new_value)
    -> jsonb_set<E, Arr, base, path, new_value> where
    base: diesel::expression::AsExpression<E>,
    path: diesel::expression::AsExpression<Arr>,
    new_value: diesel::expression::AsExpression<E> {
    jsonb_set_utils::jsonb_set {
        base: base.as_expression(),
        path: path.as_expression(),
        new_value: new_value.as_expression(),
        E: ::std::marker::PhantomData,
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_set()`](fn@jsonb_set)"]
pub type jsonb_set<E, Arr, base, path, new_value> =
    jsonb_set_utils::jsonb_set<E, Arr,
    <base as diesel::expression::AsExpression<E>>::Expression,
    <path as diesel::expression::AsExpression<Arr>>::Expression,
    <new_value as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_set_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_set<E, Arr, base, path, new_value> {
        pub(in super) base: base,
        pub(in super) path: path,
        pub(in super) new_value: new_value,
        pub(in super) E: ::std::marker::PhantomData<E>,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<E, Arr, base, path, new_value, __Rhs> ::std::ops::Add<__Rhs>
                for jsonb_set<E, Arr, base, path, new_value> 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<E, Arr, base, path, new_value, __Rhs> ::std::ops::Sub<__Rhs>
                for jsonb_set<E, Arr, base, path, new_value> 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<E, Arr, base, path, new_value, __Rhs> ::std::ops::Mul<__Rhs>
                for jsonb_set<E, Arr, base, path, new_value> 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<E, Arr, base, path, new_value, __Rhs> ::std::ops::Div<__Rhs>
                for jsonb_set<E, Arr, base, path, new_value> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, Arr: ::core::fmt::Debug,
        base: ::core::fmt::Debug, path: ::core::fmt::Debug,
        new_value: ::core::fmt::Debug> ::core::fmt::Debug for
        jsonb_set<E, Arr, base, path, new_value> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field5_finish(f, "jsonb_set",
                "base", &self.base, "path", &self.path, "new_value",
                &self.new_value, "E", &self.E, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, Arr: ::core::clone::Clone,
        base: ::core::clone::Clone, path: ::core::clone::Clone,
        new_value: ::core::clone::Clone> ::core::clone::Clone for
        jsonb_set<E, Arr, base, path, new_value> {
        #[inline]
        fn clone(&self) -> jsonb_set<E, Arr, base, path, new_value> {
            jsonb_set {
                base: ::core::clone::Clone::clone(&self.base),
                path: ::core::clone::Clone::clone(&self.path),
                new_value: ::core::clone::Clone::clone(&self.new_value),
                E: ::core::clone::Clone::clone(&self.E),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, Arr: ::core::marker::Copy,
        base: ::core::marker::Copy, path: ::core::marker::Copy,
        new_value: ::core::marker::Copy> ::core::marker::Copy for
        jsonb_set<E, Arr, base, path, new_value> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                Arr: diesel::query_builder::QueryId,
                base: diesel::query_builder::QueryId,
                path: diesel::query_builder::QueryId,
                new_value: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                jsonb_set<E, Arr, base, path, new_value> {
                type QueryId =
                    jsonb_set<<E as diesel::query_builder::QueryId>::QueryId,
                    <Arr as diesel::query_builder::QueryId>::QueryId,
                    <base as diesel::query_builder::QueryId>::QueryId,
                    <path as diesel::query_builder::QueryId>::QueryId,
                    <new_value as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                        &&
                                        <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <base as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <path as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <new_value as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                        <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    ||
                                    <base as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <path as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <new_value as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`jsonb_set()`](fn@jsonb_set)"]
    pub type HelperType<E, Arr, base, path, new_value> =
        jsonb_set<E, Arr, <base as AsExpression<E>>::Expression,
        <path as AsExpression<Arr>>::Expression,
        <new_value as AsExpression<E>>::Expression>;
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value> Expression for
        jsonb_set<E, Arr, base, path, new_value> where
        (base, path, new_value): Expression {
        type SqlType = Arr::Out;
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        jsonb_set<E, Arr, base, path, new_value> where
        base: SelectableExpression<__DieselInternal>,
        path: SelectableExpression<__DieselInternal>,
        new_value: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, __DieselInternal>
        AppearsOnTable<__DieselInternal> for
        jsonb_set<E, Arr, base, path, new_value> where
        base: AppearsOnTable<__DieselInternal>,
        path: AppearsOnTable<__DieselInternal>,
        new_value: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        jsonb_set<E, Arr, base, path, new_value> where
        __DieselInternal: diesel::backend::Backend,
        base: QueryFragment<__DieselInternal>,
        path: QueryFragment<__DieselInternal>,
        new_value: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_set";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.base.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.base.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.path.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.path.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.new_value.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.new_value.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value> QueryFragment<crate::pg::Pg> for
        jsonb_set<E, Arr, base, path, new_value> where
        base: QueryFragment<crate::pg::Pg>,
        path: QueryFragment<crate::pg::Pg>,
        new_value: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<base, path, new_value>(base, path, new_value);
    const _: () =
        {
            use diesel;
            impl<base, path, new_value, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<base, path, new_value> where
                base: diesel::expression::ValidGrouping<__GroupByClause>,
                path: diesel::expression::ValidGrouping<__GroupByClause>,
                new_value: diesel::expression::ValidGrouping<__GroupByClause>,
                <base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<path as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<new_value
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<base as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<path as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<new_value as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, __DieselInternal>
        ValidGrouping<__DieselInternal> for
        jsonb_set<E, Arr, base, path, new_value> where
        __Derived<base, path, new_value>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<base, path, new_value> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Returns target with the item designated by path replaced by new_value,"]
#[doc =
"     or with new_value added if create_if_missing is true (which is the default)"]
#[doc = "     and the item designated by path does not exist."]
#[doc = ""]
#[doc = " It can\'t set path in scalar"]
#[doc = ""]
#[doc =
" All earlier steps in the path must exist, or the target is returned unchanged."]
#[doc =
" As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays."]
#[doc = " If the last path step is an array index that is out of range,"]
#[doc =
"     and create_if_missing is true, the new value is added at the beginning of the array if the index is negative,"]
#[doc = "     or at the end of the array if it is positive."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_set_create_if_missing;"]
#[doc = " #     use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text};"]
#[doc = " #     use serde_json::{json, Value};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Array<Text>, _, _, _, _>("]
#[doc = "         json!([{\"f1\":1,\"f2\":null},2,null,3]),"]
#[doc = "         vec![\"0\",\"f1\"],"]
#[doc = "         json!([2,3,4]),"]
#[doc = "         true"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc =
" let expected: Value = json!([{\"f1\": [2, 3, 4], \"f2\": null}, 2, null, 3]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Array<Text>, _, _, _, _>("]
#[doc = "         json!([{\"f1\":1,\"f2\":null},2,null,3]),"]
#[doc = "         vec![\"0\",\"f3\"],"]
#[doc = "         json!([2,3,4]),"]
#[doc = "         false"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc =
" let expected: Value = json!([{\"f1\":1, \"f2\": null},2, null, 3]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Array<Text>, _, _, _, _>("]
#[doc = "         json!([{\"odd\":[2,4,6,8]}]),"]
#[doc = "         // not vec![\"odd\"], cannot set path in scalar"]
#[doc = "         vec![\"0\",\"odd\"],"]
#[doc = "         json!([1,3,5,7]),"]
#[doc = "         true"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = json!([{\"odd\":[1,3,5,7]}]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc = " let empty:Vec<String> = Vec::new();"]
#[doc =
" let result = diesel::select(jsonb_set_create_if_missing::<Nullable<Jsonb>, Array<Nullable<Text>>, _, _, _, _>("]
#[doc = "         None::<Value>,"]
#[doc = "         empty,"]
#[doc = "         None::<Value>,"]
#[doc = "         true"]
#[doc = "     )).get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " let empty:Vec<String> = Vec::new();"]
#[doc =
" let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Array<Nullable<Text>>, _, _, _, _>("]
#[doc = "         // cannot be json!(null)"]
#[doc = "         json!([]),"]
#[doc = "         empty,"]
#[doc = "         json!(null),"]
#[doc = "         true"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc = " let expected = json!([]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Nullable<Array<Nullable<Text>>>, _, _, _, _>("]
#[doc = "         json!(null),"]
#[doc = "         None::<Vec<String>>,"]
#[doc = "         json!({\"foo\": 42}),"]
#[doc = "         true"]
#[doc = "     )).get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_set_create_if_missing<E: JsonbOrNullableJsonb + SingleValue,
    Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>, base,
    path, new_value,
    create_if_missing>(base: base, path: path, new_value: new_value,
    create_if_missing: create_if_missing)
    ->
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> where base: diesel::expression::AsExpression<E>,
    path: diesel::expression::AsExpression<Arr>,
    new_value: diesel::expression::AsExpression<E>,
    create_if_missing: diesel::expression::AsExpression<Bool> {
    jsonb_set_create_if_missing_utils::jsonb_set_create_if_missing {
        base: base.as_expression(),
        path: path.as_expression(),
        new_value: new_value.as_expression(),
        create_if_missing: create_if_missing.as_expression(),
        E: ::std::marker::PhantomData,
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_set_create_if_missing()`](fn@jsonb_set_create_if_missing)"]
pub type
    jsonb_set_create_if_missing<E, Arr, base, path, new_value,
    create_if_missing> =
    jsonb_set_create_if_missing_utils::jsonb_set_create_if_missing<E, Arr,
    <base as diesel::expression::AsExpression<E>>::Expression,
    <path as diesel::expression::AsExpression<Arr>>::Expression,
    <new_value as diesel::expression::AsExpression<E>>::Expression,
    <create_if_missing as
    diesel::expression::AsExpression<Bool>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_set_create_if_missing_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> {
        pub(in super) base: base,
        pub(in super) path: path,
        pub(in super) new_value: new_value,
        pub(in super) create_if_missing: create_if_missing,
        pub(in super) E: ::std::marker::PhantomData<E>,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<E, Arr, base, path, new_value, create_if_missing, __Rhs>
                ::std::ops::Add<__Rhs> for
                jsonb_set_create_if_missing<E, Arr, base, path, new_value,
                create_if_missing> 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<E, Arr, base, path, new_value, create_if_missing, __Rhs>
                ::std::ops::Sub<__Rhs> for
                jsonb_set_create_if_missing<E, Arr, base, path, new_value,
                create_if_missing> 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<E, Arr, base, path, new_value, create_if_missing, __Rhs>
                ::std::ops::Mul<__Rhs> for
                jsonb_set_create_if_missing<E, Arr, base, path, new_value,
                create_if_missing> 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<E, Arr, base, path, new_value, create_if_missing, __Rhs>
                ::std::ops::Div<__Rhs> for
                jsonb_set_create_if_missing<E, Arr, base, path, new_value,
                create_if_missing> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, Arr: ::core::fmt::Debug,
        base: ::core::fmt::Debug, path: ::core::fmt::Debug,
        new_value: ::core::fmt::Debug, create_if_missing: ::core::fmt::Debug>
        ::core::fmt::Debug for
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            let names: &'static _ =
                &["base", "path", "new_value", "create_if_missing", "E",
                            "Arr"];
            let values: &[&dyn ::core::fmt::Debug] =
                &[&self.base, &self.path, &self.new_value,
                            &self.create_if_missing, &self.E, &&self.Arr];
            ::core::fmt::Formatter::debug_struct_fields_finish(f,
                "jsonb_set_create_if_missing", names, values)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, Arr: ::core::clone::Clone,
        base: ::core::clone::Clone, path: ::core::clone::Clone,
        new_value: ::core::clone::Clone,
        create_if_missing: ::core::clone::Clone> ::core::clone::Clone for
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> {
        #[inline]
        fn clone(&self)
            ->
                jsonb_set_create_if_missing<E, Arr, base, path, new_value,
                create_if_missing> {
            jsonb_set_create_if_missing {
                base: ::core::clone::Clone::clone(&self.base),
                path: ::core::clone::Clone::clone(&self.path),
                new_value: ::core::clone::Clone::clone(&self.new_value),
                create_if_missing: ::core::clone::Clone::clone(&self.create_if_missing),
                E: ::core::clone::Clone::clone(&self.E),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, Arr: ::core::marker::Copy,
        base: ::core::marker::Copy, path: ::core::marker::Copy,
        new_value: ::core::marker::Copy,
        create_if_missing: ::core::marker::Copy> ::core::marker::Copy for
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                Arr: diesel::query_builder::QueryId,
                base: diesel::query_builder::QueryId,
                path: diesel::query_builder::QueryId,
                new_value: diesel::query_builder::QueryId,
                create_if_missing: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                jsonb_set_create_if_missing<E, Arr, base, path, new_value,
                create_if_missing> {
                type QueryId =
                    jsonb_set_create_if_missing<<E as
                    diesel::query_builder::QueryId>::QueryId,
                    <Arr as diesel::query_builder::QueryId>::QueryId,
                    <base as diesel::query_builder::QueryId>::QueryId,
                    <path as diesel::query_builder::QueryId>::QueryId,
                    <new_value as diesel::query_builder::QueryId>::QueryId,
                    <create_if_missing as
                    diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                            &&
                                            <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                        &&
                                        <base as
                                            diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                    <path as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <new_value as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <create_if_missing as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                            <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                        ||
                                        <base as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    ||
                                    <path as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <new_value as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <create_if_missing as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`jsonb_set_create_if_missing()`](fn@jsonb_set_create_if_missing)"]
    pub type HelperType<E, Arr, base, path, new_value, create_if_missing> =
        jsonb_set_create_if_missing<E, Arr,
        <base as AsExpression<E>>::Expression,
        <path as AsExpression<Arr>>::Expression,
        <new_value as AsExpression<E>>::Expression,
        <create_if_missing as AsExpression<Bool>>::Expression>;
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing> Expression for
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> where
        (base, path, new_value, create_if_missing): Expression {
        type SqlType = Arr::Out;
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> where base: SelectableExpression<__DieselInternal>,
        path: SelectableExpression<__DieselInternal>,
        new_value: SelectableExpression<__DieselInternal>,
        create_if_missing: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, __DieselInternal>
        AppearsOnTable<__DieselInternal> for
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> where base: AppearsOnTable<__DieselInternal>,
        path: AppearsOnTable<__DieselInternal>,
        new_value: AppearsOnTable<__DieselInternal>,
        create_if_missing: AppearsOnTable<__DieselInternal>, Self: Expression
        {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> where __DieselInternal: diesel::backend::Backend,
        base: QueryFragment<__DieselInternal>,
        path: QueryFragment<__DieselInternal>,
        new_value: QueryFragment<__DieselInternal>,
        create_if_missing: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_set";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.base.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.base.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.path.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.path.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.new_value.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.new_value.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.create_if_missing.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.create_if_missing.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing> QueryFragment<crate::pg::Pg>
        for
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> where base: QueryFragment<crate::pg::Pg>,
        path: QueryFragment<crate::pg::Pg>,
        new_value: QueryFragment<crate::pg::Pg>,
        create_if_missing: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<base, path, new_value,
        create_if_missing>(base, path, new_value, create_if_missing);
    const _: () =
        {
            use diesel;
            impl<base, path, new_value, create_if_missing, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<base, path, new_value, create_if_missing> where
                base: diesel::expression::ValidGrouping<__GroupByClause>,
                path: diesel::expression::ValidGrouping<__GroupByClause>,
                new_value: diesel::expression::ValidGrouping<__GroupByClause>,
                create_if_missing: diesel::expression::ValidGrouping<__GroupByClause>,
                <base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<path as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<new_value
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<<base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<path as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                as
                diesel::expression::MixedAggregates<<new_value as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<create_if_missing
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<<base as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<path as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<new_value as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<create_if_missing as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, __DieselInternal>
        ValidGrouping<__DieselInternal> for
        jsonb_set_create_if_missing<E, Arr, base, path, new_value,
        create_if_missing> where
        __Derived<base, path, new_value,
        create_if_missing>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<base, path, new_value, create_if_missing> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc =
" Returns target with the item designated by path replaced by new_value,"]
#[doc =
"     or with new_value added and the item designated by path does not exist."]
#[doc = ""]
#[doc = " It can\'t set path in scalar"]
#[doc = ""]
#[doc =
" All earlier steps in the path must exist, or the target is returned unchanged."]
#[doc =
" As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays."]
#[doc = " If the last path step is an array index that is out of range,"]
#[doc =
"    the new value is added at the beginning of the array if the index is negative,"]
#[doc = "     or at the end of the array if it is positive."]
#[doc = ""]
#[doc = " If new_value is not NULL, behaves identically to jsonb_set."]
#[doc =
"    Otherwise behaves according to the value of null_value_treatment"]
#[doc =
"    which must be one of \'raise_exception\', \'use_json_null\', \'delete_key\', or \'return_target\'."]
#[doc = "    The default is \'use_json_null\'."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_set_lax;"]
#[doc =
" #     use diesel::sql_types::{Jsonb,Array,NullValueTreatment, Json, Nullable, Text};"]
#[doc = " #     use serde_json::{json,Value};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let null_value_treatment = NullValueTreatment::UseJsonNull;"]
#[doc =
" let result = diesel::select(jsonb_set_lax::<Jsonb, Array<Text>, _, _, _, _, _>("]
#[doc = "         json!([{\"f1\":1,\"f2\":null},2,null,3]),"]
#[doc = "         vec![\"0\",\"f1\"],"]
#[doc = "         json!([2,3,4]),"]
#[doc = "         true,"]
#[doc = "         null_value_treatment"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc =
" let expected: Value = json!([{\"f1\": [2, 3, 4], \"f2\": null}, 2, null, 3]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc = " let null_value_treatment = NullValueTreatment::ReturnTarget;"]
#[doc =
" let result = diesel::select(jsonb_set_lax::<Nullable<Jsonb>, Array<Nullable<Text>>, _, _, _, _, _>("]
#[doc = "         json!([{\"f1\":99,\"f2\":null},2]),"]
#[doc = "         vec![\"0\",\"f3\"],"]
#[doc = "         None::<Value>,"]
#[doc = "         true,"]
#[doc = "         null_value_treatment"]
#[doc = "     )).get_result::<Option<Value>>(connection)?;"]
#[doc = " assert_eq!(result, Some(json!([{\"f1\":99,\"f2\":null},2])));"]
#[doc = ""]
#[doc = " let null_value_treatment = NullValueTreatment::UseJsonNull;"]
#[doc = " let empty:Vec<String> = Vec::new();"]
#[doc =
" let result = diesel::select(jsonb_set_lax::<Jsonb, Array<Nullable<Text>>, _, _, _, _, _>("]
#[doc = "         // cannot be json!(null)"]
#[doc = "         json!([]),"]
#[doc = "         empty,"]
#[doc = "         json!(null),"]
#[doc = "         true,"]
#[doc = "         null_value_treatment"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc = " let expected = json!([]);"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc = " let null_value_treatment = NullValueTreatment::UseJsonNull;"]
#[doc =
" let result = diesel::select(jsonb_set_lax::<Jsonb, Nullable<Array<Nullable<Text>>>, _, _, _, _, _,>("]
#[doc = "         json!(null),"]
#[doc = "         None::<Vec<String>>,"]
#[doc = "         json!({\"foo\": 42}),"]
#[doc = "         true,"]
#[doc = "         null_value_treatment"]
#[doc = "     )).get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_set_lax<E: JsonbOrNullableJsonb + SingleValue,
    Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>, base,
    path, new_value, create_if_missing,
    null_value_treatment>(base: base, path: path, new_value: new_value,
    create_if_missing: create_if_missing,
    null_value_treatment: null_value_treatment)
    ->
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> where base: diesel::expression::AsExpression<E>,
    path: diesel::expression::AsExpression<Arr>,
    new_value: diesel::expression::AsExpression<E>,
    create_if_missing: diesel::expression::AsExpression<Bool>,
    null_value_treatment: diesel::expression::AsExpression<NullValueTreatmentEnum> {
    jsonb_set_lax_utils::jsonb_set_lax {
        base: base.as_expression(),
        path: path.as_expression(),
        new_value: new_value.as_expression(),
        create_if_missing: create_if_missing.as_expression(),
        null_value_treatment: null_value_treatment.as_expression(),
        E: ::std::marker::PhantomData,
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_set_lax()`](fn@jsonb_set_lax)"]
pub type
    jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
    null_value_treatment> =
    jsonb_set_lax_utils::jsonb_set_lax<E, Arr,
    <base as diesel::expression::AsExpression<E>>::Expression,
    <path as diesel::expression::AsExpression<Arr>>::Expression,
    <new_value as diesel::expression::AsExpression<E>>::Expression,
    <create_if_missing as diesel::expression::AsExpression<Bool>>::Expression,
    <null_value_treatment as
    diesel::expression::AsExpression<NullValueTreatmentEnum>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_set_lax_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> {
        pub(in super) base: base,
        pub(in super) path: path,
        pub(in super) new_value: new_value,
        pub(in super) create_if_missing: create_if_missing,
        pub(in super) null_value_treatment: null_value_treatment,
        pub(in super) E: ::std::marker::PhantomData<E>,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<E, Arr, base, path, new_value, create_if_missing,
                null_value_treatment, __Rhs> ::std::ops::Add<__Rhs> for
                jsonb_set_lax<E, Arr, base, path, new_value,
                create_if_missing, null_value_treatment> 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<E, Arr, base, path, new_value, create_if_missing,
                null_value_treatment, __Rhs> ::std::ops::Sub<__Rhs> for
                jsonb_set_lax<E, Arr, base, path, new_value,
                create_if_missing, null_value_treatment> 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<E, Arr, base, path, new_value, create_if_missing,
                null_value_treatment, __Rhs> ::std::ops::Mul<__Rhs> for
                jsonb_set_lax<E, Arr, base, path, new_value,
                create_if_missing, null_value_treatment> 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<E, Arr, base, path, new_value, create_if_missing,
                null_value_treatment, __Rhs> ::std::ops::Div<__Rhs> for
                jsonb_set_lax<E, Arr, base, path, new_value,
                create_if_missing, null_value_treatment> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, Arr: ::core::fmt::Debug,
        base: ::core::fmt::Debug, path: ::core::fmt::Debug,
        new_value: ::core::fmt::Debug, create_if_missing: ::core::fmt::Debug,
        null_value_treatment: ::core::fmt::Debug> ::core::fmt::Debug for
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            let names: &'static _ =
                &["base", "path", "new_value", "create_if_missing",
                            "null_value_treatment", "E", "Arr"];
            let values: &[&dyn ::core::fmt::Debug] =
                &[&self.base, &self.path, &self.new_value,
                            &self.create_if_missing, &self.null_value_treatment,
                            &self.E, &&self.Arr];
            ::core::fmt::Formatter::debug_struct_fields_finish(f,
                "jsonb_set_lax", names, values)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, Arr: ::core::clone::Clone,
        base: ::core::clone::Clone, path: ::core::clone::Clone,
        new_value: ::core::clone::Clone,
        create_if_missing: ::core::clone::Clone,
        null_value_treatment: ::core::clone::Clone> ::core::clone::Clone for
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> {
        #[inline]
        fn clone(&self)
            ->
                jsonb_set_lax<E, Arr, base, path, new_value,
                create_if_missing, null_value_treatment> {
            jsonb_set_lax {
                base: ::core::clone::Clone::clone(&self.base),
                path: ::core::clone::Clone::clone(&self.path),
                new_value: ::core::clone::Clone::clone(&self.new_value),
                create_if_missing: ::core::clone::Clone::clone(&self.create_if_missing),
                null_value_treatment: ::core::clone::Clone::clone(&self.null_value_treatment),
                E: ::core::clone::Clone::clone(&self.E),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, Arr: ::core::marker::Copy,
        base: ::core::marker::Copy, path: ::core::marker::Copy,
        new_value: ::core::marker::Copy,
        create_if_missing: ::core::marker::Copy,
        null_value_treatment: ::core::marker::Copy> ::core::marker::Copy for
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                Arr: diesel::query_builder::QueryId,
                base: diesel::query_builder::QueryId,
                path: diesel::query_builder::QueryId,
                new_value: diesel::query_builder::QueryId,
                create_if_missing: diesel::query_builder::QueryId,
                null_value_treatment: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                jsonb_set_lax<E, Arr, base, path, new_value,
                create_if_missing, null_value_treatment> {
                type QueryId =
                    jsonb_set_lax<<E as
                    diesel::query_builder::QueryId>::QueryId,
                    <Arr as diesel::query_builder::QueryId>::QueryId,
                    <base as diesel::query_builder::QueryId>::QueryId,
                    <path as diesel::query_builder::QueryId>::QueryId,
                    <new_value as diesel::query_builder::QueryId>::QueryId,
                    <create_if_missing as
                    diesel::query_builder::QueryId>::QueryId,
                    <null_value_treatment as
                    diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                                &&
                                                <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                            &&
                                            <base as
                                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                        <path as
                                            diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                    <new_value as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <create_if_missing as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <null_value_treatment as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                                <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                            ||
                                            <base as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                        ||
                                        <path as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    ||
                                    <new_value as
                                        diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                <create_if_missing as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <null_value_treatment as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`jsonb_set_lax()`](fn@jsonb_set_lax)"]
    pub type
        HelperType<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> =
        jsonb_set_lax<E, Arr, <base as AsExpression<E>>::Expression,
        <path as AsExpression<Arr>>::Expression,
        <new_value as AsExpression<E>>::Expression,
        <create_if_missing as AsExpression<Bool>>::Expression,
        <null_value_treatment as
        AsExpression<NullValueTreatmentEnum>>::Expression>;
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, null_value_treatment>
        Expression for
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> where
        (base, path, new_value, create_if_missing,
        null_value_treatment): Expression {
        type SqlType = Arr::Out;
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, null_value_treatment,
        __DieselInternal> SelectableExpression<__DieselInternal> for
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> where
        base: SelectableExpression<__DieselInternal>,
        path: SelectableExpression<__DieselInternal>,
        new_value: SelectableExpression<__DieselInternal>,
        create_if_missing: SelectableExpression<__DieselInternal>,
        null_value_treatment: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, null_value_treatment,
        __DieselInternal> AppearsOnTable<__DieselInternal> for
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> where base: AppearsOnTable<__DieselInternal>,
        path: AppearsOnTable<__DieselInternal>,
        new_value: AppearsOnTable<__DieselInternal>,
        create_if_missing: AppearsOnTable<__DieselInternal>,
        null_value_treatment: AppearsOnTable<__DieselInternal>,
        Self: Expression {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, null_value_treatment,
        __DieselInternal> FunctionFragment<__DieselInternal> for
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> where
        __DieselInternal: diesel::backend::Backend,
        base: QueryFragment<__DieselInternal>,
        path: QueryFragment<__DieselInternal>,
        new_value: QueryFragment<__DieselInternal>,
        create_if_missing: QueryFragment<__DieselInternal>,
        null_value_treatment: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_set_lax";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.base.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.base.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.path.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.path.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.new_value.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.new_value.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.create_if_missing.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.create_if_missing.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.null_value_treatment.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.null_value_treatment.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, null_value_treatment>
        QueryFragment<crate::pg::Pg> for
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> where base: QueryFragment<crate::pg::Pg>,
        path: QueryFragment<crate::pg::Pg>,
        new_value: QueryFragment<crate::pg::Pg>,
        create_if_missing: QueryFragment<crate::pg::Pg>,
        null_value_treatment: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<base, path, new_value, create_if_missing,
        null_value_treatment>(base, path, new_value, create_if_missing,
        null_value_treatment);
    const _: () =
        {
            use diesel;
            impl<base, path, new_value, create_if_missing,
                null_value_treatment, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<base, path, new_value, create_if_missing,
                null_value_treatment> where
                base: diesel::expression::ValidGrouping<__GroupByClause>,
                path: diesel::expression::ValidGrouping<__GroupByClause>,
                new_value: diesel::expression::ValidGrouping<__GroupByClause>,
                create_if_missing: diesel::expression::ValidGrouping<__GroupByClause>,
                null_value_treatment: diesel::expression::ValidGrouping<__GroupByClause>,
                <base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<path as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<new_value
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<<base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<path as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                as
                diesel::expression::MixedAggregates<<new_value as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<create_if_missing
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<<<base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<path as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                as
                diesel::expression::MixedAggregates<<new_value as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                as
                diesel::expression::MixedAggregates<<create_if_missing as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<null_value_treatment
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<<<base as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<path as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<new_value as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<create_if_missing as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<null_value_treatment as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, create_if_missing, null_value_treatment,
        __DieselInternal> ValidGrouping<__DieselInternal> for
        jsonb_set_lax<E, Arr, base, path, new_value, create_if_missing,
        null_value_treatment> where
        __Derived<base, path, new_value, create_if_missing,
        null_value_treatment>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<base, path, new_value, create_if_missing,
            null_value_treatment> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns target with `new_value` inserted into `base`."]
#[doc = ""]
#[doc =
" If the item designated by the `path` is an array element, `new_value` will be inserted before that item"]
#[doc = ""]
#[doc =
" If the item designated by the `path` is an object field, `new_value` will be"]
#[doc = " inserted only if the object does not already contain that key."]
#[doc = ""]
#[doc =
" * All earlier steps in the path must exist, or the target is returned unchanged."]
#[doc =
" * As with the path oriented operators, negative integers that appear in the `path` count"]
#[doc = "   from the end of JSON arrays."]
#[doc = " * If the last `path` step is an array index that is out of range,"]
#[doc =
"   the new value is added at the beginning of the array if the index is negative,"]
#[doc = "   or at the end of the array if it is positive."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_insert;"]
#[doc = " #     use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text};"]
#[doc = " #     use serde_json::{json,Value};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_insert::<Jsonb, Array<Text>, _, _, _>("]
#[doc = "         json!({\"a\":[0,1,2]}),"]
#[doc = "         vec![\"a\",\"1\"],"]
#[doc = "         json!(\"new_value\"),"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = json!({\"a\":[0,\"new_value\",1,2]});"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_insert::<Nullable<Jsonb>, Array<Text>, _, _, _>("]
#[doc = "         None::<serde_json::Value>,"]
#[doc = "         vec![\"a\",\"1\"],"]
#[doc = "         Some(json!(\"new_value\")),"]
#[doc = "     )).get_result::<Option<Value>>(connection)?;"]
#[doc = " assert_eq!(result, None);"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_insert<E: JsonbOrNullableJsonb + SingleValue,
    Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>, base,
    path, new_value>(base: base, path: path, new_value: new_value)
    -> jsonb_insert<E, Arr, base, path, new_value> where
    base: diesel::expression::AsExpression<E>,
    path: diesel::expression::AsExpression<Arr>,
    new_value: diesel::expression::AsExpression<E> {
    jsonb_insert_utils::jsonb_insert {
        base: base.as_expression(),
        path: path.as_expression(),
        new_value: new_value.as_expression(),
        E: ::std::marker::PhantomData,
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_insert()`](fn@jsonb_insert)"]
pub type jsonb_insert<E, Arr, base, path, new_value> =
    jsonb_insert_utils::jsonb_insert<E, Arr,
    <base as diesel::expression::AsExpression<E>>::Expression,
    <path as diesel::expression::AsExpression<Arr>>::Expression,
    <new_value as diesel::expression::AsExpression<E>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_insert_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_insert<E, Arr, base, path, new_value> {
        pub(in super) base: base,
        pub(in super) path: path,
        pub(in super) new_value: new_value,
        pub(in super) E: ::std::marker::PhantomData<E>,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<E, Arr, base, path, new_value, __Rhs> ::std::ops::Add<__Rhs>
                for jsonb_insert<E, Arr, base, path, new_value> 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<E, Arr, base, path, new_value, __Rhs> ::std::ops::Sub<__Rhs>
                for jsonb_insert<E, Arr, base, path, new_value> 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<E, Arr, base, path, new_value, __Rhs> ::std::ops::Mul<__Rhs>
                for jsonb_insert<E, Arr, base, path, new_value> 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<E, Arr, base, path, new_value, __Rhs> ::std::ops::Div<__Rhs>
                for jsonb_insert<E, Arr, base, path, new_value> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, Arr: ::core::fmt::Debug,
        base: ::core::fmt::Debug, path: ::core::fmt::Debug,
        new_value: ::core::fmt::Debug> ::core::fmt::Debug for
        jsonb_insert<E, Arr, base, path, new_value> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            ::core::fmt::Formatter::debug_struct_field5_finish(f,
                "jsonb_insert", "base", &self.base, "path", &self.path,
                "new_value", &self.new_value, "E", &self.E, "Arr", &&self.Arr)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, Arr: ::core::clone::Clone,
        base: ::core::clone::Clone, path: ::core::clone::Clone,
        new_value: ::core::clone::Clone> ::core::clone::Clone for
        jsonb_insert<E, Arr, base, path, new_value> {
        #[inline]
        fn clone(&self) -> jsonb_insert<E, Arr, base, path, new_value> {
            jsonb_insert {
                base: ::core::clone::Clone::clone(&self.base),
                path: ::core::clone::Clone::clone(&self.path),
                new_value: ::core::clone::Clone::clone(&self.new_value),
                E: ::core::clone::Clone::clone(&self.E),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, Arr: ::core::marker::Copy,
        base: ::core::marker::Copy, path: ::core::marker::Copy,
        new_value: ::core::marker::Copy> ::core::marker::Copy for
        jsonb_insert<E, Arr, base, path, new_value> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                Arr: diesel::query_builder::QueryId,
                base: diesel::query_builder::QueryId,
                path: diesel::query_builder::QueryId,
                new_value: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                jsonb_insert<E, Arr, base, path, new_value> {
                type QueryId =
                    jsonb_insert<<E as diesel::query_builder::QueryId>::QueryId,
                    <Arr as diesel::query_builder::QueryId>::QueryId,
                    <base as diesel::query_builder::QueryId>::QueryId,
                    <path as diesel::query_builder::QueryId>::QueryId,
                    <new_value as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                        &&
                                        <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                    &&
                                    <base as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <path as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <new_value as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                        <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    ||
                                    <base as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <path as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                            ||
                            <new_value as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc = "The return type of [`jsonb_insert()`](fn@jsonb_insert)"]
    pub type HelperType<E, Arr, base, path, new_value> =
        jsonb_insert<E, Arr, <base as AsExpression<E>>::Expression,
        <path as AsExpression<Arr>>::Expression,
        <new_value as AsExpression<E>>::Expression>;
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value> Expression for
        jsonb_insert<E, Arr, base, path, new_value> where
        (base, path, new_value): Expression {
        type SqlType = Arr::Out;
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        jsonb_insert<E, Arr, base, path, new_value> where
        base: SelectableExpression<__DieselInternal>,
        path: SelectableExpression<__DieselInternal>,
        new_value: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, __DieselInternal>
        AppearsOnTable<__DieselInternal> for
        jsonb_insert<E, Arr, base, path, new_value> where
        base: AppearsOnTable<__DieselInternal>,
        path: AppearsOnTable<__DieselInternal>,
        new_value: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        jsonb_insert<E, Arr, base, path, new_value> where
        __DieselInternal: diesel::backend::Backend,
        base: QueryFragment<__DieselInternal>,
        path: QueryFragment<__DieselInternal>,
        new_value: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_insert";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.base.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.base.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.path.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.path.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.new_value.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.new_value.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value> QueryFragment<crate::pg::Pg> for
        jsonb_insert<E, Arr, base, path, new_value> where
        base: QueryFragment<crate::pg::Pg>,
        path: QueryFragment<crate::pg::Pg>,
        new_value: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<base, path, new_value>(base, path, new_value);
    const _: () =
        {
            use diesel;
            impl<base, path, new_value, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<base, path, new_value> where
                base: diesel::expression::ValidGrouping<__GroupByClause>,
                path: diesel::expression::ValidGrouping<__GroupByClause>,
                new_value: diesel::expression::ValidGrouping<__GroupByClause>,
                <base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<path as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<new_value
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<base as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<path as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<new_value as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, __DieselInternal>
        ValidGrouping<__DieselInternal> for
        jsonb_insert<E, Arr, base, path, new_value> where
        __Derived<base, path, new_value>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<base, path, new_value> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}
#[doc = " Returns target with `new_value` inserted into `base`."]
#[doc = ""]
#[doc =
" If the item designated by the `path` is an array element, `new_value` will be inserted before that"]
#[doc = " item if `insert_after` is false (which is the default),"]
#[doc = " or after it if `insert_after` is true."]
#[doc = ""]
#[doc =
" If the item designated by the `path` is an object field, `new_value` will be inserted only"]
#[doc = " if the object does not already contain that key."]
#[doc = ""]
#[doc =
" * All earlier steps in the `path` must exist, or the target is returned unchanged."]
#[doc =
" * As with the path oriented operators, negative integers that appear in the `path` count"]
#[doc = "   from the end of JSON arrays."]
#[doc = " * If the last `path` step is an array index that is out of range,"]
#[doc =
"   the new value is added at the beginning of the array if the index is negative,"]
#[doc = "   or at the end of the array if it is positive."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```rust"]
#[doc = " # include!(\"../../doctest_setup.rs\");"]
#[doc = " #"]
#[doc = " # fn main() {"]
#[doc = " #     #[cfg(feature = \"serde_json\")]"]
#[doc = " #     run_test().unwrap();"]
#[doc = " # }"]
#[doc = " #"]
#[doc = " # #[cfg(feature = \"serde_json\")]"]
#[doc = " # fn run_test() -> QueryResult<()> {"]
#[doc = " #     use diesel::dsl::jsonb_insert_with_insert_after;"]
#[doc = " #     use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text};"]
#[doc = " #     use serde_json::{json,Value};"]
#[doc = " #     let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_insert_with_insert_after::<Jsonb, Array<Text>, _, _, _, _>("]
#[doc = "         json!({\"a\":[0,1,2]}),"]
#[doc = "         vec![\"a\",\"1\"],"]
#[doc = "         json!(\"new_value\"),"]
#[doc = "         false"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = json!({\"a\":[0,\"new_value\",1,2]});"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_insert_with_insert_after::<Jsonb, Array<Text>, _, _, _, _>("]
#[doc = "         json!({\"a\":[0,1,2]}),"]
#[doc = "         vec![\"a\",\"1\"],"]
#[doc = "         json!(\"new_value\"),"]
#[doc = "         true"]
#[doc = "     )).get_result::<Value>(connection)?;"]
#[doc = " let expected: Value = json!({\"a\":[0,1,\"new_value\",2,]});"]
#[doc = " assert_eq!(result, expected);"]
#[doc = ""]
#[doc = " #     Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_insert_with_insert_after<E: JsonbOrNullableJsonb + SingleValue,
    Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>, base,
    path, new_value,
    insert_after>(base: base, path: path, new_value: new_value,
    insert_after: insert_after)
    ->
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> where base: diesel::expression::AsExpression<E>,
    path: diesel::expression::AsExpression<Arr>,
    new_value: diesel::expression::AsExpression<E>,
    insert_after: diesel::expression::AsExpression<Bool> {
    jsonb_insert_with_insert_after_utils::jsonb_insert_with_insert_after {
        base: base.as_expression(),
        path: path.as_expression(),
        new_value: new_value.as_expression(),
        insert_after: insert_after.as_expression(),
        E: ::std::marker::PhantomData,
        Arr: ::std::marker::PhantomData,
    }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_insert_with_insert_after()`](fn@jsonb_insert_with_insert_after)"]
pub type
    jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
    insert_after> =
    jsonb_insert_with_insert_after_utils::jsonb_insert_with_insert_after<E,
    Arr, <base as diesel::expression::AsExpression<E>>::Expression,
    <path as diesel::expression::AsExpression<Arr>>::Expression,
    <new_value as diesel::expression::AsExpression<E>>::Expression,
    <insert_after as diesel::expression::AsExpression<Bool>>::Expression>;
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_insert_with_insert_after_utils {
    use diesel::{self, QueryResult};
    use diesel::expression::{
        AsExpression, Expression, SelectableExpression, AppearsOnTable,
        ValidGrouping,
    };
    use diesel::query_builder::{QueryFragment, AstPass};
    use diesel::sql_types::*;
    use diesel::internal::sql_functions::*;
    use super::*;
    pub struct jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> {
        pub(in super) base: base,
        pub(in super) path: path,
        pub(in super) new_value: new_value,
        pub(in super) insert_after: insert_after,
        pub(in super) E: ::std::marker::PhantomData<E>,
        pub(in super) Arr: ::std::marker::PhantomData<Arr>,
    }
    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<E, Arr, base, path, new_value, insert_after, __Rhs>
                ::std::ops::Add<__Rhs> for
                jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
                insert_after> 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<E, Arr, base, path, new_value, insert_after, __Rhs>
                ::std::ops::Sub<__Rhs> for
                jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
                insert_after> 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<E, Arr, base, path, new_value, insert_after, __Rhs>
                ::std::ops::Mul<__Rhs> for
                jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
                insert_after> 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<E, Arr, base, path, new_value, insert_after, __Rhs>
                ::std::ops::Div<__Rhs> for
                jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
                insert_after> 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())
                }
            }
        };
    #[automatically_derived]
    impl<E: ::core::fmt::Debug, Arr: ::core::fmt::Debug,
        base: ::core::fmt::Debug, path: ::core::fmt::Debug,
        new_value: ::core::fmt::Debug, insert_after: ::core::fmt::Debug>
        ::core::fmt::Debug for
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> {
        #[inline]
        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
            let names: &'static _ =
                &["base", "path", "new_value", "insert_after", "E", "Arr"];
            let values: &[&dyn ::core::fmt::Debug] =
                &[&self.base, &self.path, &self.new_value, &self.insert_after,
                            &self.E, &&self.Arr];
            ::core::fmt::Formatter::debug_struct_fields_finish(f,
                "jsonb_insert_with_insert_after", names, values)
        }
    }
    #[automatically_derived]
    impl<E: ::core::clone::Clone, Arr: ::core::clone::Clone,
        base: ::core::clone::Clone, path: ::core::clone::Clone,
        new_value: ::core::clone::Clone, insert_after: ::core::clone::Clone>
        ::core::clone::Clone for
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> {
        #[inline]
        fn clone(&self)
            ->
                jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
                insert_after> {
            jsonb_insert_with_insert_after {
                base: ::core::clone::Clone::clone(&self.base),
                path: ::core::clone::Clone::clone(&self.path),
                new_value: ::core::clone::Clone::clone(&self.new_value),
                insert_after: ::core::clone::Clone::clone(&self.insert_after),
                E: ::core::clone::Clone::clone(&self.E),
                Arr: ::core::clone::Clone::clone(&self.Arr),
            }
        }
    }
    #[automatically_derived]
    impl<E: ::core::marker::Copy, Arr: ::core::marker::Copy,
        base: ::core::marker::Copy, path: ::core::marker::Copy,
        new_value: ::core::marker::Copy, insert_after: ::core::marker::Copy>
        ::core::marker::Copy for
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> {
    }
    const _: () =
        {
            use diesel;
            #[allow(non_camel_case_types)]
            impl<E: diesel::query_builder::QueryId,
                Arr: diesel::query_builder::QueryId,
                base: diesel::query_builder::QueryId,
                path: diesel::query_builder::QueryId,
                new_value: diesel::query_builder::QueryId,
                insert_after: diesel::query_builder::QueryId>
                diesel::query_builder::QueryId for
                jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
                insert_after> {
                type QueryId =
                    jsonb_insert_with_insert_after<<E as
                    diesel::query_builder::QueryId>::QueryId,
                    <Arr as diesel::query_builder::QueryId>::QueryId,
                    <base as diesel::query_builder::QueryId>::QueryId,
                    <path as diesel::query_builder::QueryId>::QueryId,
                    <new_value as diesel::query_builder::QueryId>::QueryId,
                    <insert_after as diesel::query_builder::QueryId>::QueryId>;
                const HAS_STATIC_QUERY_ID: bool =
                    <E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                            &&
                                            <Arr as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                                        &&
                                        <base as
                                            diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                    <path as
                                        diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                                <new_value as
                                    diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                            <insert_after as
                                diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                        true;
                const IS_WINDOW_FUNCTION: bool =
                    <E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                                            <Arr as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                        ||
                                        <base as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                    ||
                                    <path as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                                ||
                                <new_value as
                                    diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                            <insert_after as
                                diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                        false;
            }
        };
    #[doc =
    "The return type of [`jsonb_insert_with_insert_after()`](fn@jsonb_insert_with_insert_after)"]
    pub type HelperType<E, Arr, base, path, new_value, insert_after> =
        jsonb_insert_with_insert_after<E, Arr,
        <base as AsExpression<E>>::Expression,
        <path as AsExpression<Arr>>::Expression,
        <new_value as AsExpression<E>>::Expression,
        <insert_after as AsExpression<Bool>>::Expression>;
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, insert_after> Expression for
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> where (base, path, new_value, insert_after): Expression
        {
        type SqlType = Arr::Out;
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, insert_after, __DieselInternal>
        SelectableExpression<__DieselInternal> for
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> where base: SelectableExpression<__DieselInternal>,
        path: SelectableExpression<__DieselInternal>,
        new_value: SelectableExpression<__DieselInternal>,
        insert_after: SelectableExpression<__DieselInternal>,
        Self: AppearsOnTable<__DieselInternal> {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, insert_after, __DieselInternal>
        AppearsOnTable<__DieselInternal> for
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> where base: AppearsOnTable<__DieselInternal>,
        path: AppearsOnTable<__DieselInternal>,
        new_value: AppearsOnTable<__DieselInternal>,
        insert_after: AppearsOnTable<__DieselInternal>, Self: Expression {}
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, insert_after, __DieselInternal>
        FunctionFragment<__DieselInternal> for
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> where __DieselInternal: diesel::backend::Backend,
        base: QueryFragment<__DieselInternal>,
        path: QueryFragment<__DieselInternal>,
        new_value: QueryFragment<__DieselInternal>,
        insert_after: QueryFragment<__DieselInternal> {
        const FUNCTION_NAME: &'static str = "jsonb_insert";
        #[allow(unused_assignments)]
        fn walk_arguments<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
            let mut needs_comma = false;
            if !self.base.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.base.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.path.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.path.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.new_value.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.new_value.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            if !self.insert_after.is_noop(out.backend())? {
                if needs_comma { out.push_sql(", "); }
                self.insert_after.walk_ast(out.reborrow())?;
                needs_comma = true;
            }
            Ok(())
        }
    }
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, insert_after> QueryFragment<crate::pg::Pg> for
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> where base: QueryFragment<crate::pg::Pg>,
        path: QueryFragment<crate::pg::Pg>,
        new_value: QueryFragment<crate::pg::Pg>,
        insert_after: QueryFragment<crate::pg::Pg> {
        fn walk_ast<'__b>(&'__b self,
            mut out: AstPass<'_, '__b, crate::pg::Pg>) -> QueryResult<()> {
            out.push_sql(<Self as
                    FunctionFragment<crate::pg::Pg>>::FUNCTION_NAME);
            out.push_sql("(");
            self.walk_arguments(out.reborrow())?;
            out.push_sql(")");
            Ok(())
        }
    }
    pub struct __Derived<base, path, new_value,
        insert_after>(base, path, new_value, insert_after);
    const _: () =
        {
            use diesel;
            impl<base, path, new_value, insert_after, __GroupByClause>
                diesel::expression::ValidGrouping<__GroupByClause> for
                __Derived<base, path, new_value, insert_after> where
                base: diesel::expression::ValidGrouping<__GroupByClause>,
                path: diesel::expression::ValidGrouping<__GroupByClause>,
                new_value: diesel::expression::ValidGrouping<__GroupByClause>,
                insert_after: diesel::expression::ValidGrouping<__GroupByClause>,
                <base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<path as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<new_value
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
                <<<base as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                as
                diesel::expression::MixedAggregates<<path as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                as
                diesel::expression::MixedAggregates<<new_value as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<insert_after
                as
                diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
                {
                type IsAggregate =
                    <<<<base as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
                    as
                    diesel::expression::MixedAggregates<<path as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<new_value as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
                    as
                    diesel::expression::MixedAggregates<<insert_after as
                    diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
            }
        };
    impl<E: JsonbOrNullableJsonb + SingleValue,
        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
        base, path, new_value, insert_after, __DieselInternal>
        ValidGrouping<__DieselInternal> for
        jsonb_insert_with_insert_after<E, Arr, base, path, new_value,
        insert_after> where
        __Derived<base, path, new_value,
        insert_after>: ValidGrouping<__DieselInternal> {
        type IsAggregate =
            <__Derived<base, path, new_value, insert_after> as
            ValidGrouping<__DieselInternal>>::IsAggregate;
    }
}#[declare_sql_function]
19#[backends(crate::pg::Pg)]
20extern "SQL" {
21    /// Creates an abbreviated display format as text.
22    #[cfg(feature = "postgres_backend")]
23    fn abbrev<T: InetOrCidr + SingleValue>(addr: T) -> Text;
24
25    /// Computes the broadcast address for the address's network.
26    #[cfg(feature = "postgres_backend")]
27    fn broadcast<T: InetOrCidr + SingleValue>(addr: T) -> Inet;
28
29    /// Returns the address's family: 4 for IPv4, 6 for IPv6.
30    #[cfg(feature = "postgres_backend")]
31    fn family<T: InetOrCidr + SingleValue>(addr: T) -> Integer;
32
33    /// Returns the IP address as text, ignoring the netmask.
34    #[cfg(feature = "postgres_backend")]
35    fn host<T: InetOrCidr + SingleValue>(addr: T) -> Text;
36
37    /// Computes the host mask for the address's network.
38    #[cfg(feature = "postgres_backend")]
39    fn hostmask<T: InetOrCidr + SingleValue>(addr: T) -> Inet;
40
41    /// Computes the smallest network that includes both of the given networks.
42    #[cfg(feature = "postgres_backend")]
43    fn inet_merge<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue>(a: T, b: U) -> Cidr;
44
45    /// Tests whether the addresses belong to the same IP family.
46    #[cfg(feature = "postgres_backend")]
47    fn inet_same_family<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue>(
48        a: T,
49        b: U,
50    ) -> Bool;
51
52    /// Returns the netmask length in bits.
53    #[cfg(feature = "postgres_backend")]
54    fn masklen<T: InetOrCidr + SingleValue>(addr: T) -> Integer;
55
56    /// Computes the network mask for the address's network.
57    #[cfg(feature = "postgres_backend")]
58    fn netmask<T: InetOrCidr + SingleValue>(addr: T) -> Inet;
59
60    /// Returns the network part of the address, zeroing out whatever is to the right of the
61    /// netmask. (This is equivalent to casting the value to cidr.)
62    #[cfg(feature = "postgres_backend")]
63    fn network<T: InetOrCidr + SingleValue>(addr: T) -> Cidr;
64
65    /// Sets the netmask length for an inet or cidr value.
66    /// For inet, the address part does not changes. For cidr, address bits to the right of the new
67    /// netmask are set to zero.
68    #[cfg(feature = "postgres_backend")]
69    fn set_masklen<T: InetOrCidr + SingleValue>(addr: T, len: Integer) -> T;
70
71    /// Returns the lower bound of the range
72    ///
73    /// If the range is empty or has no lower bound, it returns NULL.
74    ///
75    /// # Example
76    ///
77    /// ```rust
78    /// # include!("../../doctest_setup.rs");
79    /// #
80    /// # fn main() {
81    /// #     run_test().unwrap();
82    /// # }
83    /// #
84    /// # fn run_test() -> QueryResult<()> {
85    /// # use diesel::pg::sql_types::{Range, Multirange};
86    /// # use diesel::dsl::lower;
87    /// #     use std::collections::Bound;
88    /// #     use diesel::sql_types::{Nullable, Integer, Array};
89    /// #     let connection = &mut establish_connection();
90    /// let int = diesel::select(lower::<Range<_>, _>(1..2)).get_result::<Option<i32>>(connection)?;
91    /// assert_eq!(Some(1), int);
92    ///
93    /// let int = diesel::select(lower::<Range<_>, _>(..2)).get_result::<Option<i32>>(connection)?;
94    /// assert_eq!(None, int);
95    ///
96    /// let int = diesel::select(lower::<Nullable<Range<_>>, _>(None::<std::ops::Range<i32>>))
97    ///     .get_result::<Option<i32>>(connection)?;
98    /// assert_eq!(None, int);
99    ///
100    /// let int = diesel::select(lower::<Multirange<_>, _>(vec![5..7]))
101    ///     .get_result::<Option<i32>>(connection)?;
102    /// assert_eq!(Some(5), int);
103    /// #     Ok(())
104    /// # }
105    /// ```
106    #[cfg(feature = "postgres_backend")]
107    fn lower<R: MultirangeOrRangeMaybeNullable + SingleValue>(range: R) -> Nullable<R::Inner>;
108
109    /// Returns the upper bound of the range
110    ///
111    /// If the range is empty or has no upper bound, it returns NULL.
112    ///
113    /// # Example
114    ///
115    /// ```rust
116    /// # include!("../../doctest_setup.rs");
117    /// #
118    /// # fn main() {
119    /// #     run_test().unwrap();
120    /// # }
121    /// #
122    /// # fn run_test() -> QueryResult<()> {
123    /// # use diesel::pg::sql_types::{Range, Multirange};
124    /// # use diesel::dsl::upper;
125    /// #     use std::collections::Bound;
126    /// #     use diesel::sql_types::{Nullable, Integer, Array};
127    /// #     let connection = &mut establish_connection();
128    /// let int = diesel::select(upper::<Range<_>, _>(1..2)).get_result::<Option<i32>>(connection)?;
129    /// assert_eq!(Some(2), int);
130    ///
131    /// let int = diesel::select(upper::<Range<_>, _>(1..)).get_result::<Option<i32>>(connection)?;
132    /// assert_eq!(None, int);
133    ///
134    /// let int = diesel::select(upper::<Nullable<Range<_>>, _>(None::<std::ops::Range<i32>>))
135    ///     .get_result::<Option<i32>>(connection)?;
136    /// assert_eq!(None, int);
137    ///
138    /// let int = diesel::select(upper::<Multirange<_>, _>(vec![5..7]))
139    ///     .get_result::<Option<i32>>(connection)?;
140    /// assert_eq!(Some(7), int);
141    /// #     Ok(())
142    /// # }
143    /// ```
144    #[cfg(feature = "postgres_backend")]
145    fn upper<R: MultirangeOrRangeMaybeNullable + SingleValue>(range: R) -> Nullable<R::Inner>;
146
147    /// Returns true if the range is empty
148    ///
149    /// # Example
150    ///
151    /// ```rust
152    /// # include!("../../doctest_setup.rs");
153    /// #
154    /// # fn main() {
155    /// #     run_test().unwrap();
156    /// # }
157    /// #
158    /// # fn run_test() -> QueryResult<()> {
159    /// # use diesel::pg::sql_types::{Range, Multirange};
160    /// # use diesel::dsl::isempty;
161    /// #     use std::collections::Bound;
162    /// #     use diesel::sql_types::{Nullable, Integer, Array};
163    /// #     let connection = &mut establish_connection();
164    /// let int = diesel::select(isempty::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;
165    /// assert_eq!(false, int);
166    ///
167    /// let int = diesel::select(isempty::<Range<Integer>, _>(1..1)).get_result::<bool>(connection)?;
168    /// assert_eq!(true, int);
169    ///
170    /// let int = diesel::select(isempty::<Nullable<Range<Integer>>, _>(
171    ///     None::<std::ops::Range<i32>>,
172    /// ))
173    /// .get_result::<Option<bool>>(connection)?;
174    /// assert_eq!(None, int);
175    ///
176    /// let int = diesel::select(isempty::<Multirange<Integer>, _>(vec![5..7]))
177    ///     .get_result::<bool>(connection)?;
178    /// assert_eq!(false, int);
179    /// #     Ok(())
180    /// # }
181    /// ```
182    #[cfg(feature = "postgres_backend")]
183    fn isempty<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
184        range: R,
185    ) -> R::Out;
186
187    /// Returns true if the range's lower bound is inclusive
188    ///
189    /// # Example
190    ///
191    /// ```rust
192    /// # include!("../../doctest_setup.rs");
193    /// #
194    /// # fn main() {
195    /// #     run_test().unwrap();
196    /// # }
197    /// #
198    /// # fn run_test() -> QueryResult<()> {
199    /// # use diesel::pg::sql_types::{Range, Multirange};
200    /// # use diesel::dsl::lower_inc;
201    /// #     use std::collections::Bound;
202    /// #     use diesel::sql_types::{Nullable, Integer, Array};
203    /// #     let connection = &mut establish_connection();
204    /// let int =
205    ///     diesel::select(lower_inc::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;
206    /// assert_eq!(true, int);
207    ///
208    /// let int = diesel::select(lower_inc::<Range<Integer>, _>(..5)).get_result::<bool>(connection)?;
209    /// assert_eq!(false, int);
210    ///
211    /// let int = diesel::select(lower_inc::<Nullable<Range<Integer>>, _>(
212    ///     None::<std::ops::Range<i32>>,
213    /// ))
214    /// .get_result::<Option<bool>>(connection)?;
215    /// assert_eq!(None, int);
216    ///
217    /// let int = diesel::select(lower_inc::<Multirange<Integer>, _>(vec![5..7]))
218    ///     .get_result::<bool>(connection)?;
219    /// assert_eq!(true, int);
220    /// #     Ok(())
221    /// # }
222    /// ```
223    #[cfg(feature = "postgres_backend")]
224    fn lower_inc<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
225        range: R,
226    ) -> R::Out;
227
228    /// Returns true if the range's upper bound is inclusive
229    ///
230    /// # Example
231    ///
232    /// ```rust
233    /// # include!("../../doctest_setup.rs");
234    /// #
235    /// # fn main() {
236    /// #     run_test().unwrap();
237    /// # }
238    /// #
239    /// # fn run_test() -> QueryResult<()> {
240    /// # use diesel::pg::sql_types::{Range, Multirange};
241    /// # use diesel::dsl::upper_inc;
242    /// #     use std::collections::Bound;
243    /// #     use diesel::sql_types::{Nullable, Integer, Array};
244    /// #     let connection = &mut establish_connection();
245    /// let int =
246    ///     diesel::select(upper_inc::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;
247    /// assert_eq!(false, int);
248    ///
249    /// let int = diesel::select(upper_inc::<Nullable<Range<Integer>>, _>(
250    ///     None::<std::ops::Range<i32>>,
251    /// ))
252    /// .get_result::<Option<bool>>(connection)?;
253    /// assert_eq!(None, int);
254    ///
255    /// let int = diesel::select(upper_inc::<Multirange<Integer>, _>(vec![5..7]))
256    ///     .get_result::<bool>(connection)?;
257    /// assert_eq!(false, int);
258    /// #     Ok(())
259    /// # }
260    /// ```
261    #[cfg(feature = "postgres_backend")]
262    fn upper_inc<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
263        range: R,
264    ) -> R::Out;
265
266    /// Returns true if the range's lower bound is unbounded
267    ///
268    /// # Example
269    ///
270    /// ```rust
271    /// # include!("../../doctest_setup.rs");
272    /// #
273    /// # fn main() {
274    /// #     run_test().unwrap();
275    /// # }
276    /// #
277    /// # fn run_test() -> QueryResult<()> {
278    /// # use diesel::pg::sql_types::{Range, Multirange};
279    /// # use diesel::dsl::lower_inf;
280    /// #     use std::collections::Bound;
281    /// #     use diesel::sql_types::{Nullable, Integer, Array};
282    /// #     let connection = &mut establish_connection();
283    /// let int =
284    ///     diesel::select(lower_inf::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;
285    /// assert_eq!(false, int);
286    ///
287    /// let int = diesel::select(lower_inf::<Range<Integer>, _>(..5)).get_result::<bool>(connection)?;
288    /// assert_eq!(true, int);
289    ///
290    /// let int = diesel::select(lower_inf::<Nullable<Range<Integer>>, _>(
291    ///     None::<std::ops::Range<i32>>,
292    /// ))
293    /// .get_result::<Option<bool>>(connection)?;
294    /// assert_eq!(None, int);
295    ///
296    /// let int = diesel::select(lower_inf::<Multirange<Integer>, _>(vec![5..7]))
297    ///     .get_result::<bool>(connection)?;
298    /// assert_eq!(false, int);
299    /// #     Ok(())
300    /// # }
301    /// ```
302    #[cfg(feature = "postgres_backend")]
303    fn lower_inf<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
304        range: R,
305    ) -> R::Out;
306
307    /// Returns true if the range's upper bound is unbounded
308    ///
309    /// # Example
310    ///
311    /// ```rust
312    /// # include!("../../doctest_setup.rs");
313    /// #
314    /// # fn main() {
315    /// #     run_test().unwrap();
316    /// # }
317    /// #
318    /// # fn run_test() -> QueryResult<()> {
319    /// # use diesel::pg::sql_types::{Range, Multirange};
320    /// # use diesel::dsl::upper_inf;
321    /// #     use std::collections::Bound;
322    /// #     use diesel::sql_types::{Nullable, Integer, Array};
323    /// #     let connection = &mut establish_connection();
324    /// let int =
325    ///     diesel::select(upper_inf::<Range<Integer>, _>(1..5)).get_result::<bool>(connection)?;
326    /// assert_eq!(false, int);
327    ///
328    /// let int = diesel::select(upper_inf::<Range<Integer>, _>(1..)).get_result::<bool>(connection)?;
329    /// assert_eq!(true, int);
330    ///
331    /// let int = diesel::select(upper_inf::<Nullable<Range<Integer>>, _>(
332    ///     None::<std::ops::Range<i32>>,
333    /// ))
334    /// .get_result::<Option<bool>>(connection)?;
335    /// assert_eq!(None, int);
336    ///
337    /// let int = diesel::select(upper_inf::<Multirange<Integer>, _>(vec![5..7]))
338    ///     .get_result::<bool>(connection)?;
339    /// assert_eq!(false, int);
340    /// #     Ok(())
341    /// # }
342    /// ```
343    #[cfg(feature = "postgres_backend")]
344    fn upper_inf<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
345        range: R,
346    ) -> R::Out;
347
348    /// Returns the smallest range which includes both of the given ranges
349    ///
350    /// # Example
351    ///
352    /// ```rust
353    /// # include!("../../doctest_setup.rs");
354    /// #
355    /// # fn main() {
356    /// #     run_test().unwrap();
357    /// # }
358    /// #
359    /// # fn run_test() -> QueryResult<()> {
360    /// # use diesel::pg::sql_types::{Range, Multirange};
361    /// # use diesel::dsl::range_merge;
362    /// #     use std::collections::Bound;
363    /// #     use diesel::sql_types::{Nullable, Integer, Array};
364    /// #     let connection = &mut establish_connection();
365    /// let int = diesel::select(range_merge::<Range<Integer>, Range<_>, _, _>(5..11, 10..))
366    ///     .get_result::<(Bound<i32>, Bound<i32>)>(connection)?;
367    /// assert_eq!((Bound::Included(5), Bound::Unbounded), int);
368    ///
369    /// let int = diesel::select(range_merge::<Range<Integer>, Range<_>, _, _>(1..3, 7..10))
370    ///     .get_result::<(Bound<i32>, Bound<i32>)>(connection)?;
371    /// assert_eq!((Bound::Included(1), Bound::Excluded(10)), int);
372    ///
373    /// let int = diesel::select(range_merge::<
374    ///     Nullable<Range<Integer>>,
375    ///     Nullable<Range<_>>,
376    ///     _,
377    ///     _,
378    /// >(None::<std::ops::Range<i32>>, 7..10))
379    /// .get_result::<Option<(Bound<i32>, Bound<i32>)>>(connection)?;
380    /// assert_eq!(None, int);
381    ///
382    /// let int = diesel::select(range_merge::<
383    ///     Nullable<Range<Integer>>,
384    ///     Nullable<Range<_>>,
385    ///     _,
386    ///     _,
387    /// >(1..3, None::<std::ops::Range<i32>>))
388    /// .get_result::<Option<(Bound<i32>, Bound<i32>)>>(connection)?;
389    /// assert_eq!(None, int);
390    /// #     Ok(())
391    /// # }
392    /// ```
393    #[cfg(feature = "postgres_backend")]
394    fn range_merge<
395        R1: RangeOrNullableRange + SingleValue,
396        R2: RangeOrNullableRange<Inner = R1::Inner>
397            + SingleValue
398            + CombinedNullableValue<R1, Range<R1::Inner>>,
399    >(
400        lhs: R1,
401        rhs: R2,
402    ) -> R2::Out;
403
404    /// Returns the smallest range which includes all ranges in the multirange
405    ///
406    /// # Example
407    ///
408    /// ```rust
409    /// # include!("../../doctest_setup.rs");
410    /// #
411    /// # fn main() {
412    /// #     run_test().unwrap();
413    /// # }
414    /// #
415    /// # fn run_test() -> QueryResult<()> {
416    /// # use diesel::pg::sql_types::{Range, Multirange};
417    /// # use diesel::dsl::multirange_merge;
418    /// #     use std::collections::Bound;
419    /// #     use diesel::sql_types::{Nullable, Integer, Array};
420    /// #     let connection = &mut establish_connection();
421    /// let int = diesel::select(multirange_merge::<Multirange<Integer>, _>(vec![
422    ///     1..3,
423    ///     7..10,
424    /// ]))
425    /// .get_result::<(Bound<i32>, Bound<i32>)>(connection)?;
426    /// assert_eq!((Bound::Included(1), Bound::Excluded(10)), int);
427    ///
428    /// let int = diesel::select(multirange_merge::<Nullable<Multirange<Integer>>, _>(
429    ///     None::<Vec<std::ops::Range<i32>>>,
430    /// ))
431    /// .get_result::<Option<(Bound<i32>, Bound<i32>)>>(connection)?;
432    /// assert_eq!(None, int);
433    /// #     Ok(())
434    /// # }
435    /// ```
436    #[cfg(feature = "postgres_backend")]
437    #[sql_name = "range_merge"]
438    fn multirange_merge<R: MultirangeOrNullableMultirange + SingleValue>(multirange: R)
439        -> R::Range;
440
441    /// Returns range of integer
442    ///
443    /// # Example
444    ///
445    /// ```rust
446    /// # include!("../../doctest_setup.rs");
447    /// #
448    /// # table! {
449    /// #     posts {
450    /// #         id -> Integer,
451    /// #         versions -> Int4range,
452    /// #     }
453    /// # }
454    /// #
455    /// # fn main() {
456    /// #     run_test().unwrap();
457    /// # }
458    /// #
459    /// # fn run_test() -> QueryResult<()> {
460    /// #     use self::posts::dsl::*;
461    /// #     use std::collections::Bound;
462    /// #     let conn = &mut establish_connection();
463    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();
464    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT4RANGE NOT NULL)").execute(conn).unwrap();
465    /// #
466    /// use diesel::dsl::int4range;
467    /// use diesel::pg::sql_types::RangeBound;
468    ///
469    /// diesel::insert_into(posts)
470    ///     .values(&[
471    ///        versions.eq(int4range(Some(3), Some(5), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),
472    ///        versions.eq(int4range(None, Some(2), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),
473    ///     ]).execute(conn)?;
474    ///
475    /// let cool_posts = posts.select(versions)
476    ///     .load::<(Bound<i32>, Bound<i32>)>(conn)?;
477    /// assert_eq!(vec![
478    ///          (Bound::Included(3), Bound::Excluded(6)), // Postgres cast this internally
479    ///          (Bound::Unbounded, Bound::Excluded(2)),
480    ///      ], cool_posts);
481    /// #     Ok(())
482    /// # }
483    /// ```
484    #[cfg(feature = "postgres_backend")]
485    fn int4range(
486        lower: Nullable<Integer>,
487        upper: Nullable<Integer>,
488        bound: RangeBoundEnum,
489    ) -> Int4range;
490
491    /// Returns range of big ints
492    ///
493    /// # Example
494    ///
495    /// ```rust
496    /// # include!("../../doctest_setup.rs");
497    /// #
498    /// # table! {
499    /// #     posts {
500    /// #         id -> Integer,
501    /// #         versions -> Int8range,
502    /// #     }
503    /// # }
504    /// #
505    /// # fn main() {
506    /// #     run_test().unwrap();
507    /// # }
508    /// #
509    /// # fn run_test() -> QueryResult<()> {
510    /// #     use self::posts::dsl::*;
511    /// #     use std::collections::Bound;
512    /// #     let conn = &mut establish_connection();
513    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();
514    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT8RANGE NOT NULL)").execute(conn).unwrap();
515    /// #
516    /// use diesel::dsl::int8range;
517    /// use diesel::pg::sql_types::RangeBound;
518    ///
519    /// diesel::insert_into(posts)
520    ///     .values(&[
521    ///        versions.eq(int8range(Some(3), Some(5), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),
522    ///        versions.eq(int8range(None, Some(2), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),
523    ///     ]).execute(conn)?;
524    ///
525    /// let cool_posts = posts.select(versions)
526    ///     .load::<(Bound<i64>, Bound<i64>)>(conn)?;
527    /// assert_eq!(vec![
528    ///          (Bound::Included(3), Bound::Excluded(6)), // Postgres cast this internally
529    ///          (Bound::Unbounded, Bound::Excluded(2)),
530    ///      ], cool_posts);
531    /// #     Ok(())
532    /// # }
533    /// ```
534    #[cfg(feature = "postgres_backend")]
535    fn int8range(
536        lower: Nullable<BigInt>,
537        upper: Nullable<BigInt>,
538        bound: RangeBoundEnum,
539    ) -> Int8range;
540
541    /// Returns range of numeric values
542    ///
543    /// # Example
544    ///
545    /// ```rust
546    /// # include!("../../doctest_setup.rs");
547    /// #
548    /// # table! {
549    /// #     posts {
550    /// #         id -> Integer,
551    /// #         versions -> Numrange,
552    /// #     }
553    /// # }
554    /// #
555    /// # fn main() {
556    /// #     #[cfg(feature = "numeric")]
557    /// #     run_test().unwrap();
558    /// # }
559    /// #
560    /// # #[cfg(feature = "numeric")]
561    /// # fn run_test() -> QueryResult<()> {
562    /// #     use self::posts::dsl::*;
563    /// #     use std::collections::Bound;
564    /// #     let conn = &mut establish_connection();
565    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();
566    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions NUMRANGE NOT NULL)").execute(conn).unwrap();
567    /// #
568    /// # use bigdecimal::BigDecimal;
569    /// use diesel::dsl::numrange;
570    /// use diesel::pg::sql_types::RangeBound;
571    ///
572    /// diesel::insert_into(posts)
573    ///     .values(&[
574    ///        versions.eq(numrange(Some(BigDecimal::from(3)), Some(BigDecimal::from(5)), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),
575    ///        versions.eq(numrange(None, Some(BigDecimal::from(2)), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),
576    ///     ]).execute(conn)?;
577    ///
578    /// let cool_posts = posts.select(versions)
579    ///     .load::<(Bound<BigDecimal>, Bound<BigDecimal>)>(conn)?;
580    /// assert_eq!(vec![
581    ///          (Bound::Included(BigDecimal::from(3)), Bound::Included(BigDecimal::from(5))),
582    ///          (Bound::Unbounded, Bound::Excluded(BigDecimal::from(2))),
583    ///      ], cool_posts);
584    /// #     Ok(())
585    /// # }
586    /// ```
587    #[cfg(feature = "postgres_backend")]
588    fn numrange(
589        lower: Nullable<Numeric>,
590        upper: Nullable<Numeric>,
591        bound: RangeBoundEnum,
592    ) -> Numrange;
593
594    /// Returns range of timestamps without timezone
595    ///
596    /// # Example
597    ///
598    /// ```rust
599    /// # include!("../../doctest_setup.rs");
600    /// #
601    /// # table! {
602    /// #     posts {
603    /// #         id -> Integer,
604    /// #         versions -> Tsrange,
605    /// #     }
606    /// # }
607    /// #
608    /// # fn main() {
609    /// #     #[cfg(feature = "time")]
610    /// #     run_test().unwrap();
611    /// # }
612    /// #
613    /// # #[cfg(feature = "time")]
614    /// # fn run_test() -> QueryResult<()> {
615    /// #     use self::posts::dsl::*;
616    /// #     use std::collections::Bound;
617    /// #     let conn = &mut establish_connection();
618    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();
619    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions TSRANGE NOT NULL)").execute(conn).unwrap();
620    /// #
621    /// use diesel::dsl::tsrange;
622    /// use diesel::pg::sql_types::RangeBound;
623    /// use time::{PrimitiveDateTime, macros::datetime};
624    ///
625    /// diesel::insert_into(posts)
626    ///     .values(&[
627    ///        versions.eq(tsrange(Some(datetime!(2020-01-01 0:00)), Some(datetime!(2021-01-01 0:00)), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),
628    ///        versions.eq(tsrange(None, Some(datetime!(2020-01-01 0:00)), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),
629    ///     ]).execute(conn)?;
630    ///
631    /// let cool_posts = posts.select(versions)
632    ///     .load::<(Bound<PrimitiveDateTime>, Bound<PrimitiveDateTime>)>(conn)?;
633    /// assert_eq!(vec![
634    ///          (Bound::Included(datetime!(2020-01-01 0:00)), Bound::Included(datetime!(2021-01-01 0:00))),
635    ///          (Bound::Unbounded, Bound::Excluded(datetime!(2020-01-01 0:00))),
636    ///      ], cool_posts);
637    /// #     Ok(())
638    /// # }
639    /// ```
640    #[cfg(feature = "postgres_backend")]
641    fn tsrange(
642        lower: Nullable<Timestamp>,
643        upper: Nullable<Timestamp>,
644        bound: RangeBoundEnum,
645    ) -> Tsrange;
646
647    /// Returns range of timestamps with timezone
648    ///
649    /// # Example
650    ///
651    /// ```rust
652    /// # include!("../../doctest_setup.rs");
653    /// #
654    /// # table! {
655    /// #     posts {
656    /// #         id -> Integer,
657    /// #         versions -> Tstzrange,
658    /// #     }
659    /// # }
660    /// #
661    /// # fn main() {
662    /// #     #[cfg(feature = "time")]
663    /// #     run_test().unwrap();
664    /// # }
665    /// #
666    /// # #[cfg(feature = "time")]
667    /// # fn run_test() -> QueryResult<()> {
668    /// #     use self::posts::dsl::*;
669    /// #     use std::collections::Bound;
670    /// #     let conn = &mut establish_connection();
671    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();
672    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions TSTZRANGE NOT NULL)").execute(conn).unwrap();
673    /// #
674    /// use diesel::dsl::tstzrange;
675    /// use diesel::pg::sql_types::RangeBound;
676    /// use time::{OffsetDateTime, macros::datetime};
677    ///
678    /// diesel::insert_into(posts)
679    ///     .values(&[
680    ///        versions.eq(tstzrange(Some(datetime!(2020-01-01 0:00 UTC)), Some(datetime!(2021-01-01 0:00 -3)), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),
681    ///        versions.eq(tstzrange(None, Some(datetime!(2020-01-01 0:00 +2)), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),
682    ///     ]).execute(conn)?;
683    ///
684    /// let cool_posts = posts.select(versions)
685    ///     .load::<(Bound<OffsetDateTime>, Bound<OffsetDateTime>)>(conn)?;
686    /// assert_eq!(vec![
687    ///          (Bound::Included(datetime!(2020-01-01 0:00 UTC)), Bound::Included(datetime!(2021-01-01 0:00 -3))),
688    ///          (Bound::Unbounded, Bound::Excluded(datetime!(2020-01-01 0:00 +2))),
689    ///      ], cool_posts);
690    /// #     Ok(())
691    /// # }
692    /// ```
693    #[cfg(feature = "postgres_backend")]
694    fn tstzrange(
695        lower: Nullable<Timestamptz>,
696        upper: Nullable<Timestamptz>,
697        bound: RangeBoundEnum,
698    ) -> Tstzrange;
699
700    /// Returns range of dates
701    ///
702    /// # Example
703    ///
704    /// ```rust
705    /// # include!("../../doctest_setup.rs");
706    /// #
707    /// # table! {
708    /// #     posts {
709    /// #         id -> Integer,
710    /// #         versions -> Daterange,
711    /// #     }
712    /// # }
713    /// #
714    /// # fn main() {
715    /// #     #[cfg(feature = "time")]
716    /// #     run_test().unwrap();
717    /// # }
718    /// #
719    /// # #[cfg(feature = "time")]
720    /// # fn run_test() -> QueryResult<()> {
721    /// #     use self::posts::dsl::*;
722    /// #     use std::collections::Bound;
723    /// #     let conn = &mut establish_connection();
724    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();
725    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions DATERANGE NOT NULL)").execute(conn).unwrap();
726    /// #
727    /// use diesel::dsl::daterange;
728    /// use diesel::pg::sql_types::RangeBound;
729    /// use time::{Date, macros::date};
730    ///
731    /// diesel::insert_into(posts)
732    ///     .values(&[
733    ///        versions.eq(daterange(Some(date!(2020-01-01)), Some(date!(2021-01-01)), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),
734    ///        versions.eq(daterange(None, Some(date!(2020-01-01)), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),
735    ///     ]).execute(conn)?;
736    ///
737    /// let cool_posts = posts.select(versions)
738    ///     .load::<(Bound<Date>, Bound<Date>)>(conn)?;
739    /// assert_eq!(vec![
740    ///          (Bound::Included(date!(2020-01-01)), Bound::Excluded(date!(2021-01-02))),
741    ///          (Bound::Unbounded, Bound::Excluded(date!(2020-01-01))),
742    ///      ], cool_posts);
743    /// #     Ok(())
744    /// # }
745    /// ```
746    #[cfg(feature = "postgres_backend")]
747    fn daterange(lower: Nullable<Date>, upper: Nullable<Date>, bound: RangeBoundEnum) -> Daterange;
748
749    /// Append an element to the end of an array
750    ///
751    /// # Example
752    ///
753    /// ```rust
754    /// # include!("../../doctest_setup.rs");
755    /// #
756    /// # fn main() {
757    /// #     run_test().unwrap();
758    /// # }
759    /// #
760    /// # fn run_test() -> QueryResult<()> {
761    /// #     use diesel::dsl::array_append;
762    /// #     use diesel::sql_types::{Nullable, Integer, Array};
763    /// #     let connection = &mut establish_connection();
764    /// let ints = diesel::select(array_append::<Array<_>, Integer, _, _>(vec![1, 2], 3))
765    ///     .get_result::<Vec<i32>>(connection)?;
766    /// assert_eq!(vec![1, 2, 3], ints);
767    ///
768    /// let ints = diesel::select(array_append::<Array<_>, Nullable<Integer>, _, _>(
769    ///     vec![Some(1), Some(2)],
770    ///     None::<i32>,
771    /// ))
772    /// .get_result::<Vec<Option<i32>>>(connection)?;
773    /// assert_eq!(vec![Some(1), Some(2), None], ints);
774    ///
775    /// let ints = diesel::select(array_append::<Nullable<Array<_>>, Integer, _, _>(
776    ///     None::<Vec<i32>>,
777    ///     3,
778    /// ))
779    /// .get_result::<Vec<i32>>(connection)?;
780    /// assert_eq!(vec![3], ints);
781    ///
782    /// let ints = diesel::select(array_append::<Nullable<Array<_>>, Nullable<Integer>, _, _>(
783    ///     None::<Vec<i32>>,
784    ///     None::<i32>,
785    /// ))
786    /// .get_result::<Vec<Option<i32>>>(connection)?;
787    /// assert_eq!(vec![None], ints);
788    /// #     Ok(())
789    /// # }
790    /// ```
791    #[cfg(feature = "postgres_backend")]
792    fn array_append<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue>(
793        a: Arr,
794        e: T,
795    ) -> Array<T>;
796
797    /// Replace all occurrences of an element in an array with a given element
798    ///
799    /// # Example
800    ///
801    /// ```rust
802    /// # include!("../../doctest_setup.rs");
803    /// #
804    /// # fn main() {
805    /// #     run_test().unwrap();
806    /// # }
807    /// #
808    /// # fn run_test() -> QueryResult<()> {
809    /// #     use diesel::dsl::array_replace;
810    /// #     use diesel::sql_types::{Nullable, Integer, Array};
811    /// #     let connection = &mut establish_connection();
812    /// let ints = diesel::select(array_replace::<Array<_>, Integer, _, _, _>(
813    ///     vec![1, 2, 5, 4],
814    ///     5,
815    ///     3,
816    /// ))
817    /// .get_result::<Vec<i32>>(connection)?;
818    /// assert_eq!(vec![1, 2, 3, 4], ints);
819    ///
820    /// let ints = diesel::select(array_replace::<Array<_>, Nullable<Integer>, _, _, _>(
821    ///     vec![Some(1), Some(2), Some(3)],
822    ///     Some(3),
823    ///     None::<i32>,
824    /// ))
825    /// .get_result::<Vec<Option<i32>>>(connection)?;
826    /// assert_eq!(vec![Some(1), Some(2), None], ints);
827    ///
828    /// let ints = diesel::select(array_replace::<Nullable<Array<_>>, Integer, _, _, _>(
829    ///     None::<Vec<i32>>,
830    ///     1,
831    ///     2,
832    /// ))
833    /// .get_result::<Option<Vec<i32>>>(connection)?;
834    ///
835    /// let ints = diesel::select(array_replace::<
836    ///     Nullable<Array<_>>,
837    ///     Nullable<Integer>,
838    ///     _,
839    ///     _,
840    ///     _,
841    /// >(None::<Vec<i32>>, None::<i32>, Some(1)))
842    /// .get_result::<Option<Vec<Option<i32>>>>(connection)?;
843    /// assert_eq!(None, ints);
844    /// #    Ok(())
845    /// # }
846    /// ```
847    #[cfg(feature = "postgres_backend")]
848    fn array_replace<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue>(
849        a: Arr,
850        e: T,
851        r: T,
852    ) -> Arr;
853
854    /// Returns a text representation of the array's dimensions
855    ///
856    /// # Example
857    ///
858    /// ```rust
859    /// # include!("../../doctest_setup.rs");
860    /// #
861    /// # fn main(){
862    /// #    run_test().unwrap();
863    /// # }
864    /// # fn run_test()->QueryResult<()>{
865    /// #   use diesel::dsl::array_dims;
866    /// #   use diesel::sql_types::{Nullable,Array,Integer};
867    /// #   let connection = &mut establish_connection();
868    ///
869    /// let dims = diesel::select(array_dims::<Array<Integer>,_>(vec![1,2]))
870    ///     .get_result::<String>(connection)?;
871    /// assert!(String::from("[1:2]").eq(&dims));
872    ///
873    /// let dims = diesel::select(array_dims::<Array<Nullable<Integer>>,_>(vec![None::<i32>,Some(2)]))
874    ///     .get_result::<String>(connection)?;
875    /// assert!(String::from("[1:2]").eq(&dims));
876    ///
877    /// let dims = diesel::select(array_dims::<Array<Nullable<Integer>>,_>(vec![None::<i32>]))
878    ///     .get_result::<String>(connection)?;
879    /// assert!(String::from("[1:1]").eq(&dims));
880    /// # Ok(())
881    /// # }
882    #[cfg(feature = "postgres_backend")]
883    fn array_dims<Arr: ArrayOrNullableArray + SingleValue>(arr: Arr) -> Text;
884
885    /// Prepends an element to the beginning of an array
886    ///
887    /// # Example
888    ///
889    /// ```rust
890    /// # include!("../../doctest_setup.rs");
891    /// #
892    /// # fn main() {
893    /// #     run_test().unwrap();
894    /// # }
895    /// #
896    /// # fn run_test() -> QueryResult<()> {
897    /// #     use diesel::dsl::array_prepend;
898    /// #     use diesel::sql_types::{Nullable, Integer, Array};
899    /// #     let connection = &mut establish_connection();
900    /// let ints = diesel::select(array_prepend::<Integer, Array<_>, _, _>(3, vec![1, 2]))
901    ///     .get_result::<Vec<i32>>(connection)?;
902    /// assert_eq!(vec![3, 1, 2], ints);
903    ///
904    /// let ints = diesel::select(array_prepend::<Nullable<Integer>, Array<_>, _, _>(
905    ///     None::<i32>,
906    ///     vec![Some(1), Some(2)],
907    /// ))
908    /// .get_result::<Vec<Option<i32>>>(connection)?;
909    /// assert_eq!(vec![None, Some(1), Some(2)], ints);
910    ///
911    /// let ints = diesel::select(array_prepend::<Integer, Nullable<Array<_>>, _, _>(
912    ///     3,
913    ///     None::<Vec<i32>>,
914    /// ))
915    /// .get_result::<Vec<i32>>(connection)?;
916    /// assert_eq!(vec![3], ints);
917    ///
918    /// let ints = diesel::select(
919    ///     array_prepend::<Nullable<Integer>, Nullable<Array<_>>, _, _>(None::<i32>, None::<Vec<i32>>),
920    /// )
921    /// .get_result::<Vec<Option<i32>>>(connection)?;
922    /// assert_eq!(vec![None], ints);
923    /// #     Ok(())
924    /// # }
925    /// ```
926    #[cfg(feature = "postgres_backend")]
927    fn array_prepend<T: SingleValue, Arr: ArrayOrNullableArray<Inner = T> + SingleValue>(
928        e: T,
929        a: Arr,
930    ) -> Array<T>;
931
932    /// Removes all elements equal to the given value from the array
933    ///
934    /// # Example
935    ///
936    /// ```rust
937    /// # include!("../../doctest_setup.rs");
938    /// #
939    /// # fn main() {
940    /// #     run_test().unwrap();
941    /// # }
942    /// #
943    /// # fn run_test() -> QueryResult<()> {
944    /// #     use diesel::dsl::array_remove;
945    /// #     use diesel::sql_types::{Nullable, Integer, Array};
946    /// #     let connection = &mut establish_connection();
947    /// let ints = diesel::select(array_remove::<Array<_>, Integer, _, _>(vec![1, 2, 3, 2], 2))
948    ///     .get_result::<Vec<i32>>(connection)?;
949    /// assert_eq!(vec![1, 3], ints);
950    ///
951    /// let ints = diesel::select(array_remove::<Array<_>, Nullable<Integer>, _, _>(
952    ///     vec![None, Some(1), Some(2), None, Some(4)],
953    ///     None::<i32>,
954    /// ))
955    /// .get_result::<Vec<Option<i32>>>(connection)?;
956    /// assert_eq!(vec![Some(1), Some(2), Some(4)], ints);
957    ///
958    /// let ints = diesel::select(array_remove::<Nullable<Array<_>>, Nullable<Integer>, _, _>(
959    ///     None::<Vec<i32>>,
960    ///     None::<i32>,
961    /// ))
962    /// .get_result::<Option<Vec<Option<i32>>>>(connection)?;
963    /// assert_eq!(None, ints);
964    /// #     Ok(())
965    /// # }
966    /// ```
967    #[cfg(feature = "postgres_backend")]
968    fn array_remove<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue>(
969        a: Arr,
970        e: T,
971    ) -> Arr;
972
973    /// Converts each array element to its text representation and concatenates those elements
974    /// separated by the delimiter string. If `null_string` is provided and is not `NULL`, then `NULL`
975    /// array entries are represented by that string; otherwise, they are omitted.
976    ///
977    /// # Example
978    ///
979    /// ```rust
980    /// # include!("../../doctest_setup.rs");
981    /// #
982    /// # fn main() {
983    /// #     run_test().unwrap();
984    /// # }
985    /// #
986    /// # fn run_test() -> QueryResult<()> {
987    /// #     use diesel::dsl::array_to_string_with_null_string;
988    /// #     use diesel::sql_types::{Nullable, Text, Array};
989    /// #     let connection = &mut establish_connection();
990    ///
991    /// // Example with `NULL` representation as a string
992    /// let result: String = diesel::select(array_to_string_with_null_string::<
993    ///     Array<Nullable<Text>>,
994    ///     _,
995    ///     _,
996    ///     _,
997    /// >(
998    ///     vec![Some("first"), None::<&str>, Some("third")],
999    ///     ",",
1000    ///     "NULL",
1001    /// ))
1002    /// .get_result(connection)?;
1003    /// assert_eq!(result, "first,NULL,third");
1004    ///
1005    /// // Example without any `NULL` values
1006    /// let result: String = diesel::select(array_to_string_with_null_string::<
1007    ///     Array<Nullable<Text>>,
1008    ///     _,
1009    ///     _,
1010    ///     _,
1011    /// >(vec![Some("first"), Some("second")], ",", "NULL"))
1012    /// .get_result(connection)?;
1013    /// assert_eq!(result, "first,second");
1014    ///
1015    /// // Example with all `NULL` values
1016    /// let result: String = diesel::select(array_to_string_with_null_string::<
1017    ///     Array<Nullable<Text>>,
1018    ///     _,
1019    ///     _,
1020    ///     _,
1021    /// >(vec![None::<&str>, None::<&str>], ",", "NULL"))
1022    /// .get_result(connection)?;
1023    /// assert_eq!(result, "NULL,NULL");
1024    ///
1025    /// #     Ok(())
1026    /// # }
1027    /// ```
1028    #[cfg(feature = "postgres_backend")]
1029    #[sql_name = "array_to_string"]
1030    fn array_to_string_with_null_string<Arr: ArrayOrNullableArray + SingleValue>(
1031        array: Arr,
1032        del: Text,
1033        null: Text,
1034    ) -> Text;
1035
1036    /// Converts each array element to its text representation and concatenates those elements
1037    /// separated by the delimiter string. `NULL` entries are omitted in this variant.
1038    /// See [array_to_string_with_null_string](array_to_string_with_null_string()) for a variant with that argument.
1039    ///
1040    /// # Example
1041    ///
1042    /// ```rust
1043    /// # include!("../../doctest_setup.rs");
1044    /// #
1045    /// # fn main() {
1046    /// #     run_test().unwrap();
1047    /// # }
1048    /// #
1049    /// # fn run_test() -> QueryResult<()> {
1050    /// #     use diesel::dsl::array_to_string;
1051    /// #     use diesel::sql_types::{Text, Array, Nullable};
1052    /// #     let connection = &mut establish_connection();
1053    ///
1054    /// // Example with non-null values
1055    /// let result: String = diesel::select(array_to_string::<Array<Nullable<Text>>, _, _>(
1056    ///     vec![Some("first"), Some("second")],
1057    ///     ",",
1058    /// ))
1059    /// .get_result(connection)?;
1060    /// assert_eq!(result, "first,second");
1061    ///
1062    /// // Example with `NULL` values (omitted in the result)
1063    /// let result: String = diesel::select(array_to_string::<Array<Nullable<Text>>, _, _>(
1064    ///     vec![Some("first"), None::<&str>, Some("third")],
1065    ///     ",",
1066    /// ))
1067    /// .get_result(connection)?;
1068    /// assert_eq!(result, "first,third");
1069    ///
1070    /// // Example with only `NULL` values (empty result)
1071    /// let result: String = diesel::select(array_to_string::<Array<Nullable<Text>>, _, _>(
1072    ///     vec![None::<&str>, None::<&str>],
1073    ///     ",",
1074    /// ))
1075    /// .get_result(connection)?;
1076    /// assert_eq!(result, "");
1077    ///
1078    /// #     Ok(())
1079    /// # }
1080    /// ```
1081    #[cfg(feature = "postgres_backend")]
1082    fn array_to_string<Arr: ArrayOrNullableArray + SingleValue>(array: Arr, del: Text) -> Text;
1083
1084    /// Returns the total number of elements in the array, or 0 if the array is empty.
1085    ///
1086    /// # Example
1087    ///
1088    /// ```rust
1089    /// # include!("../../doctest_setup.rs");
1090    /// #
1091    /// # fn main(){
1092    /// #    run_test().unwrap();
1093    /// # }
1094    /// # fn run_test()->QueryResult<()>{
1095    /// #   use diesel::dsl::cardinality;
1096    /// #   use diesel::sql_types::{Nullable,Array,Integer};
1097    /// #   let connection = &mut establish_connection();
1098    ///
1099    /// let array_cardinality = diesel::select(cardinality::<Array<Integer>, _>(vec![1, 2, 3, 4]))
1100    ///     .get_result::<i32>(connection)?;
1101    /// assert_eq!(4, array_cardinality);
1102    ///
1103    /// let array_cardinality = diesel::select(cardinality::<Array<Nullable<Integer>>, _>(vec![Some(1), Some(2), Some(3)]))
1104    ///     .get_result::<i32>(connection)?;
1105    /// assert_eq!(3, array_cardinality);
1106    ///
1107    /// let array_cardinality = diesel::select(cardinality::<Array<Integer>, _>(Vec::<i32>::new()))
1108    ///     .get_result::<i32>(connection)?;
1109    /// assert_eq!(0, array_cardinality);
1110    ///
1111    /// let array_cardinality = diesel::select(cardinality::<Nullable<Array<Integer>>, _>(None::<Vec<i32>>))
1112    ///     .get_result::<Option<i32>>(connection)?;
1113    /// assert_eq!(None, array_cardinality);
1114    /// # Ok(())
1115    /// # }
1116    #[cfg(feature = "postgres_backend")]
1117    fn cardinality<Arr: ArrayOrNullableArray + SingleValue + MaybeNullableValue<Integer>>(
1118        a: Arr,
1119    ) -> Arr::Out;
1120
1121    /// Trims an array by removing the last n elements. If the array is multidimensional, only the first dimension is trimmed.
1122    ///
1123    /// # Example
1124    ///
1125    /// ```rust
1126    /// # include!("../../doctest_setup.rs");
1127    /// #
1128    /// # fn main(){
1129    /// #    run_test().unwrap();
1130    /// # }
1131    /// # fn run_test()->QueryResult<()>{
1132    /// #   use diesel::dsl::trim_array;
1133    /// #   use diesel::sql_types::{Nullable,Array,Integer};
1134    /// #   let connection = &mut establish_connection();
1135    ///
1136    /// let trimmed_array = diesel::select(trim_array::<Array<Integer>, _, _>(vec![1, 2, 3, 4], 3))
1137    ///     .get_result::<Vec<i32>>(connection)?;
1138    /// assert_eq!(vec![1], trimmed_array);
1139    ///
1140    /// let trimmed_array = diesel::select(trim_array::<Array<Nullable<Integer>>, _, _>(vec![Some(1), Some(2), Some(3)], 1))
1141    ///     .get_result::<Vec<Option<i32>>>(connection)?;
1142    /// assert_eq!(vec![Some(1), Some(2)], trimmed_array);
1143    ///
1144    /// let trimmed_array = diesel::select(trim_array::<Array<Integer>, _, _>(Vec::<i32>::new(), 0))
1145    ///     .get_result::<Vec<i32>>(connection)?;
1146    /// assert_eq!(Vec::<i32>::new(), trimmed_array);
1147    ///
1148    /// let trimmed_array = diesel::select(trim_array::<Nullable<Array<Integer>>, _, _>(None::<Vec<i32>>, 0))
1149    ///     .get_result::<Option<Vec<i32>>>(connection)?;
1150    /// assert_eq!(None, trimmed_array);
1151    ///
1152    /// let trimmed_array = diesel::select(trim_array::<Nullable<Array<Integer>>, _, _>(None::<Vec<i32>>, 1))
1153    ///     .get_result::<Option<Vec<i32>>>(connection)?;
1154    /// assert_eq!(None, trimmed_array);
1155    /// # Ok(())
1156    /// # }
1157    #[cfg(feature = "postgres_backend")]
1158    fn trim_array<Arr: ArrayOrNullableArray + SingleValue>(a: Arr, n: Integer) -> Arr;
1159
1160    /// Concatenates two arrays
1161    ///
1162    /// # Example
1163    ///
1164    /// ```rust
1165    /// # include!("../../doctest_setup.rs");
1166    /// #
1167    /// # fn main() {
1168    /// #     run_test().unwrap();
1169    /// # }
1170    /// #
1171    /// # fn run_test() -> QueryResult<()> {
1172    /// #     use diesel::dsl::array_cat;
1173    /// #     use diesel::sql_types::{Integer, Array, Nullable};
1174    /// #     let connection = &mut establish_connection();
1175    /// let result = diesel::select(array_cat::<Array<Integer>, _, _>(vec![1, 2], vec![3, 4]))
1176    ///     .get_result::<Vec<i32>>(connection)?;
1177    /// assert_eq!(vec![1, 2, 3, 4], result);
1178    ///
1179    /// let nullable_result = diesel::select(array_cat::<Nullable<Array<Integer>>, _, _>(
1180    ///     None::<Vec<i32>>,
1181    ///     None::<Vec<i32>>,
1182    /// ))
1183    /// .get_result::<Option<Vec<i32>>>(connection)?;
1184    /// assert_eq!(None, nullable_result);
1185    /// #     Ok(())
1186    /// # }
1187    /// ```
1188    #[cfg(feature = "postgres_backend")]
1189    fn array_cat<Arr: ArrayOrNullableArray + SingleValue>(a: Arr, b: Arr) -> Arr;
1190
1191    /// Returns the length of the requested array
1192    ///
1193    /// # Example
1194    ///
1195    /// ```rust
1196    /// # include!("../../doctest_setup.rs");
1197    /// #
1198    /// # fn main() {
1199    /// #     run_test().unwrap();
1200    /// # }
1201    /// #
1202    /// # fn run_test() -> QueryResult<()> {
1203    /// #     use diesel::dsl::array_length;
1204    /// #     use diesel::sql_types::{Integer, Array, Nullable};
1205    /// #     let connection = &mut establish_connection();
1206    /// let result = diesel::select(array_length::<Array<Integer>, _, _>(vec![1, 2, 3], 1))
1207    ///     .get_result::<Option<i32>>(connection)?;
1208    /// assert_eq!(Some(3), result);
1209    ///
1210    /// let result = diesel::select(array_length::<Array<Integer>, _, _>(vec![1, 2, 3], 2))
1211    ///     .get_result::<Option<i32>>(connection)?;
1212    /// assert_eq!(None, result);
1213    ///
1214    /// let result = diesel::select(array_length::<Nullable<Array<Integer>>, _, _>(
1215    ///     None::<Vec<i32>>,
1216    ///     1,
1217    /// ))
1218    /// .get_result::<Option<i32>>(connection)?;
1219    /// assert_eq!(None, result);
1220    /// #     Ok(())
1221    /// # }
1222    /// ```
1223    #[cfg(feature = "postgres_backend")]
1224    fn array_length<Arr: ArrayOrNullableArray + SingleValue>(
1225        array: Arr,
1226        dimension: Integer,
1227    ) -> Nullable<Integer>;
1228
1229    /// Returns an array initialized with supplied value and dimensions,
1230    /// optionally with lower bounds other than 1. This function omits the optional
1231    /// lower bound argument. See [array_fill_with_lower_bound](array_fill_with_lower_bound()) for that.
1232    ///
1233    /// # Example
1234    ///
1235    /// ```rust
1236    /// # include!("../../doctest_setup.rs");
1237    /// #
1238    /// # fn main(){
1239    /// #    run_test().unwrap();
1240    /// # }
1241    /// # fn run_test()->QueryResult<()>{
1242    /// #   use diesel::dsl::array_fill;
1243    /// #   use diesel::sql_types::{Nullable,Array,Integer,Text};
1244    /// #   let connection = &mut establish_connection();
1245    ///
1246    /// let array = diesel::select(array_fill::<Integer,_,_>(2,vec![2]))
1247    /// .get_result::<Vec<i32>>(connection)?;
1248    /// assert_eq!(vec![2,2],array);
1249    ///
1250    /// let array = diesel::select(array_fill::<Text,_,_>(String::from("abc"),vec![3]))
1251    /// .get_result::<Vec<String>>(connection)?;
1252    /// assert_eq!(vec!["abc","abc","abc"],array);
1253    ///
1254    /// let array = diesel::select(array_fill::<Nullable<Integer>,_,_>(Some(4),vec![3]))
1255    /// .get_result::<Vec<Option<i32>>>(connection)?;
1256    /// assert_eq!(vec![Some(4),Some(4),Some(4)],array);
1257    ///
1258    /// let array = diesel::select(array_fill::<Nullable<Integer>,_,_>(None::<i32>,vec![3]))
1259    /// .get_result::<Vec<Option<i32>>>(connection)?;
1260    /// assert_eq!(vec![None::<i32>,None::<i32>,None::<i32>],array);
1261    /// # Ok(())
1262    /// # }
1263    #[cfg(feature = "postgres_backend")]
1264    fn array_fill<E: SingleValue>(value: E, dim: Array<Integer>) -> Array<E>;
1265
1266    /// Returns an array initialized with supplied value and dimensions,
1267    /// with lower bounds other than 1
1268    ///
1269    /// # Example
1270    ///
1271    /// ```rust
1272    /// # include!("../../doctest_setup.rs");
1273    /// #
1274    /// # fn main(){
1275    /// #    run_test().unwrap();
1276    /// # }
1277    /// # fn run_test()->QueryResult<()>{
1278    /// #   use diesel::dsl::array_fill_with_lower_bound;
1279    /// #   use diesel::sql_types::{Nullable,Array,Integer,Text};
1280    /// #   let connection = &mut establish_connection();
1281    ///
1282    /// let array = diesel::select(array_fill_with_lower_bound::<Integer,_,_,_>(2,vec![2],vec![2]))
1283    /// .get_result::<Vec<i32>>(connection)?;
1284    /// assert_eq!(vec![2,2],array);
1285    ///
1286    /// let array = diesel::select(array_fill_with_lower_bound::<Text,_,_,_>(String::from("abc"),vec![3],vec![3]))
1287    /// .get_result::<Vec<String>>(connection)?;
1288    /// assert_eq!(vec!["abc","abc","abc"],array);
1289    ///
1290    /// let array = diesel::select(array_fill_with_lower_bound::<Nullable<Integer>,_,_,_>(Some(4),vec![3],vec![3]))
1291    /// .get_result::<Vec<Option<i32>>>(connection)?;
1292    /// assert_eq!(vec![Some(4),Some(4),Some(4)],array);
1293    ///
1294    /// let array = diesel::select(array_fill_with_lower_bound::<Nullable<Integer>,_,_,_>(None::<i32>,vec![3],vec![3]))
1295    /// .get_result::<Vec<Option<i32>>>(connection)?;
1296    /// assert_eq!(vec![None::<i32>,None::<i32>,None::<i32>],array);
1297    /// # Ok(())
1298    /// # }
1299    #[sql_name = "array_fill"]
1300    #[cfg(feature = "postgres_backend")]
1301    fn array_fill_with_lower_bound<E: SingleValue>(
1302        value: E,
1303        dim: Array<Integer>,
1304        lower_bound: Array<Integer>,
1305    ) -> Array<E>;
1306
1307    /// Returns the lower bound of the requested array
1308    ///
1309    /// This function returns null for dimensions that do not exist
1310    ///
1311    /// # Example
1312    ///
1313    /// ```rust
1314    /// # include!("../../doctest_setup.rs");
1315    /// #
1316    /// # fn main() {
1317    /// #     run_test().unwrap();
1318    /// # }
1319    /// #
1320    /// # fn run_test() -> QueryResult<()> {
1321    /// #     use diesel::dsl::array_lower;
1322    /// #     use diesel::sql_types::{Integer, Array};
1323    /// #     let connection = &mut establish_connection();
1324    /// let result = diesel::select(array_lower::<Array<Integer>, _, _>(vec![1, 2, 3], 1))
1325    ///     .get_result::<Option<i32>>(connection)?;
1326    /// assert_eq!(Some(1), result);
1327    ///
1328    /// // the array has only one dimension
1329    /// let result = diesel::select(array_lower::<Array<Integer>, _, _>(vec![1, 2, 3], 2))
1330    ///     .get_result::<Option<i32>>(connection)?;
1331    /// assert_eq!(None, result);
1332    /// #     Ok(())
1333    /// # }
1334    /// ```
1335    #[cfg(feature = "postgres_backend")]
1336    fn array_lower<Arr: ArrayOrNullableArray + SingleValue>(
1337        array: Arr,
1338        dimension: Integer,
1339    ) -> Nullable<Integer>;
1340
1341    /// Returns the subscript of the first occurrence of the second argument in the array, or NULL if it's not present.
1342    /// If the third argument is given, the search begins at that subscript. This function omits the third argument.
1343    /// See [array_position_with_subscript](array_position_with_subscript()).
1344    ///
1345    /// The array must be one-dimensional. Comparisons are done using IS NOT DISTINCT FROM semantics,
1346    /// so it is possible to search for NULL.
1347    ///
1348    /// # Example
1349    ///
1350    /// ```rust
1351    /// # include!("../../doctest_setup.rs");
1352    /// #
1353    /// # fn main(){
1354    /// #    run_test().unwrap();
1355    /// # }
1356    /// # fn run_test()->QueryResult<()>{
1357    /// #   use diesel::dsl::array_position;
1358    /// #   use diesel::sql_types::{Nullable,Array,Integer};
1359    /// #   let connection = &mut establish_connection();
1360    ///
1361    /// let pos = diesel::select(array_position::<Array<_>, Integer, _, _>(vec![1, 2, 3, 4], 3))
1362    ///     .get_result::<Option<i32>>(connection)?;
1363    /// assert_eq!(Some(3), pos);
1364    ///
1365    /// let pos = diesel::select(array_position::<Array<_>, Integer, _, _>(vec![1, 2, 3, 4], 5))
1366    ///     .get_result::<Option<i32>>(connection)?;
1367    /// assert_eq!(None::<i32>, pos);
1368    ///
1369    /// let pos = diesel::select(array_position::<Array<_>, Nullable<Integer>, _, _>(
1370    ///     vec![1, 2, 3, 4], None::<i32>))
1371    ///     .get_result::<Option<i32>>(connection)?;
1372    /// assert_eq!(None::<i32>, pos);
1373    ///
1374    /// let pos = diesel::select(array_position::<Array<_>, Nullable<Integer>, _, _>(
1375    ///     vec![None::<i32>, Some(1), Some(2), Some(3)], None::<i32>))
1376    ///     .get_result::<Option<i32>>(connection)?;
1377    /// assert_eq!(Some(1), pos);
1378    ///
1379    /// let dims = diesel::select(array_position::<Nullable<Array<Integer>>, Integer, _, _>(None::<Vec<i32>>, 1))
1380    ///     .get_result::<Option<i32>>(connection)?;
1381    /// assert_eq!(None, dims);
1382    ///
1383    /// # Ok(())
1384    /// # }
1385    #[cfg(feature = "postgres_backend")]
1386    fn array_position<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue>(
1387        a: Arr,
1388        elem: E,
1389    ) -> Nullable<Integer>;
1390
1391    /// Returns the subscript of the first occurrence of the second argument in the array,
1392    /// or NULL if it's not present, beginning at the subscript given as the third argument.
1393    ///
1394    /// The array must be one-dimensional.
1395    /// Comparisons are done using IS NOT DISTINCT FROM semantics,
1396    /// so it is possible to search for NULL.
1397    /// # Example
1398    ///
1399    /// ```rust
1400    /// # include!("../../doctest_setup.rs");
1401    /// #
1402    /// # fn main(){
1403    /// #    run_test().unwrap();
1404    /// # }
1405    /// # fn run_test()->QueryResult<()>{
1406    /// #   use diesel::dsl::array_position_with_subscript;
1407    /// #   use diesel::sql_types::{Nullable,Array,Integer};
1408    /// #   let connection = &mut establish_connection();
1409    ///
1410    /// let pos = diesel::select(array_position_with_subscript::<Array<_>, Integer, _, _, _>(
1411    ///     vec![1, 2, 3, 4], 3, 2))
1412    ///     .get_result::<Option<i32>>(connection)?;
1413    /// assert_eq!(Some(3), pos);
1414    ///
1415    /// let pos = diesel::select(array_position_with_subscript::<Array<_>, Integer, _, _, _>(
1416    ///     vec![1, 2, 3, 4], 1, 2))
1417    ///     .get_result::<Option<i32>>(connection)?;
1418    /// assert_eq!(None::<i32>, pos);
1419    ///
1420    /// let pos = diesel::select(array_position_with_subscript::<Array<_>, Nullable<Integer>, _, _, _>(
1421    ///     vec![None::<i32>, Some(1), Some(2), Some(3)], None::<i32>, 1))
1422    ///     .get_result::<Option<i32>>(connection)?;
1423    /// assert_eq!(Some(1), pos);
1424    ///
1425    /// let pos = diesel::select(array_position_with_subscript::<Array<_>, Nullable<Integer>, _, _, _>(
1426    ///     vec![None::<i32>, Some(1), Some(2), Some(3)], None::<i32>, 2))
1427    ///     .get_result::<Option<i32>>(connection)?;
1428    /// assert_eq!(None::<i32>, pos);
1429    /// # Ok(())
1430    /// # }
1431    #[sql_name = "array_position"]
1432    #[cfg(feature = "postgres_backend")]
1433    fn array_position_with_subscript<
1434        Arr: ArrayOrNullableArray<Inner = E> + SingleValue,
1435        E: SingleValue,
1436    >(
1437        a: Arr,
1438        elem: E,
1439        subscript: Integer,
1440    ) -> Nullable<Integer>;
1441
1442    /// Returns an array of the subscripts of all occurrences of the second argument in the
1443    /// array given as first argument.
1444    ///
1445    /// The array must be one-dimensional. Comparisons are done using IS NOT DISTINCT FROM semantics,
1446    /// so it is possible to search for NULL.
1447    /// NULL is returned only if the array is NULL; if the value is not found in the array, an empty array is returned.
1448    ///
1449    /// # Example
1450    ///
1451    /// ```rust
1452    /// # include!("../../doctest_setup.rs");
1453    /// #
1454    /// # fn main(){
1455    /// #    run_test().unwrap();
1456    /// # }
1457    /// # fn run_test()->QueryResult<()>{
1458    /// #   use diesel::dsl::array_positions;
1459    /// #   use diesel::sql_types::{Nullable,Array,Integer};
1460    /// #   let connection = &mut establish_connection();
1461    ///
1462    /// let pos = diesel::select(array_positions::<Array<_>, Integer, _, _>(vec![1, 1, 2, 1], 1))
1463    ///     .get_result::<Vec<i32>>(connection)?;
1464    /// assert_eq!(vec![1,2,4], pos);
1465    ///
1466    /// let pos = diesel::select(array_positions::<Array<_>, Integer, _, _>(vec![1, 2, 3, 4], 5))
1467    ///     .get_result::<Vec<i32>>(connection)?;
1468    /// assert_eq!(Vec::<i32>::new(), pos);
1469    ///
1470    /// let pos = diesel::select(array_positions::<Array<_>, Nullable<Integer>, _, _>(
1471    ///     vec![None::<i32>, Some(2), Some(3), None::<i32>], None::<i32>))
1472    ///     .get_result::<Vec<i32>>(connection)?;
1473    /// assert_eq!(vec![1,4], pos);
1474    ///
1475    /// let pos = diesel::select(array_positions::<Nullable<Array<_>>, Integer, _, _>(
1476    ///     None::<Vec<i32>>, 1))
1477    ///     .get_result::<Option<Vec<i32>>>(connection)?;
1478    /// assert_eq!(None::<Vec<i32>>, pos);
1479    /// # Ok(())
1480    /// # }
1481    #[cfg(feature = "postgres_backend")]
1482    fn array_positions<
1483        Arr: ArrayOrNullableArray<Inner = E> + SingleValue + MaybeNullableValue<Array<Integer>>,
1484        E: SingleValue,
1485    >(
1486        a: Arr,
1487        elem: E,
1488    ) -> Arr::Out;
1489
1490    /// Returns the number of dimensions of the array
1491    ///
1492    /// # Example
1493    ///
1494    /// ```rust
1495    /// # include!("../../doctest_setup.rs");
1496    /// #
1497    /// # fn main() {
1498    /// #     run_test().unwrap();
1499    /// # }
1500    /// #
1501    /// # fn run_test() -> QueryResult<()> {
1502    /// #     use diesel::dsl::array_ndims;
1503    /// #     use diesel::sql_types::{Nullable, Array, Integer};
1504    /// #     let connection = &mut establish_connection();
1505    ///
1506    /// // diesel currently only supports 1D arrays
1507    /// let dims = diesel::select(array_ndims::<Array<Integer>, _>(vec![1, 2]))
1508    ///     .get_result::<i32>(connection)?;
1509    /// assert_eq!(1, dims);
1510    ///
1511    /// let dims = diesel::select(array_ndims::<Nullable<Array<Integer>>, _>(None::<Vec<i32>>))
1512    ///     .get_result::<Option<i32>>(connection)?;
1513    /// assert_eq!(None, dims);
1514    ///
1515    /// #     Ok(())
1516    /// # }
1517    /// ```
1518    #[cfg(feature = "postgres_backend")]
1519    fn array_ndims<Arr: ArrayOrNullableArray + SingleValue + MaybeNullableValue<Integer>>(
1520        arr: Arr,
1521    ) -> Arr::Out;
1522
1523    /// Returns the upper bound of the requested array
1524    ///
1525    /// This function returns null for dimensions that do not exist
1526    ///
1527    /// # Example
1528    ///
1529    /// ```rust
1530    /// # include!("../../doctest_setup.rs");
1531    /// #
1532    /// # fn main() {
1533    /// #     run_test().unwrap();
1534    /// # }
1535    /// #
1536    /// # fn run_test() -> QueryResult<()> {
1537    /// #     use diesel::dsl::array_upper;
1538    /// #     use diesel::sql_types::{Integer, Array};
1539    /// #     let connection = &mut establish_connection();
1540    /// let result = diesel::select(array_upper::<Array<Integer>, _, _>(vec![1, 2, 3], 1))
1541    ///     .get_result::<Option<i32>>(connection)?;
1542    /// assert_eq!(Some(3), result);
1543    ///
1544    /// // the array has only one dimension
1545    /// let result = diesel::select(array_upper::<Array<Integer>, _, _>(vec![1, 2, 3], 2))
1546    ///     .get_result::<Option<i32>>(connection)?;
1547    /// assert_eq!(None, result);
1548    /// #     Ok(())
1549    /// # }
1550    /// ```
1551    #[cfg(feature = "postgres_backend")]
1552    fn array_upper<Arr: ArrayOrNullableArray + SingleValue>(
1553        array: Arr,
1554        dimension: Integer,
1555    ) -> Nullable<Integer>;
1556
1557    /// Randomly shuffles the first dimension of the array.
1558    ///
1559    /// # Example
1560    // This function requires postgres >= 16.0
1561    // which we cannot expect to be widely used at the
1562    // point of writing this comment, so we skip running this test
1563    /// ```rust,no_run
1564    /// # include!("../../doctest_setup.rs");
1565    /// #
1566    /// # fn main() {
1567    /// #     run_test().unwrap();
1568    /// # }
1569    /// #
1570    /// # fn run_test() -> QueryResult<()> {
1571    /// #     use diesel::dsl::array_shuffle;
1572    /// #     use diesel::sql_types::{Array, Integer};
1573    /// #     let connection = &mut establish_connection();
1574    /// let shuffled = diesel::select(array_shuffle::<Array<Integer>, _>(vec![1, 2, 3, 4, 5]))
1575    ///     .get_result::<Vec<i32>>(connection)?;
1576    /// assert_eq!(5, shuffled.len());
1577    /// assert_eq!(shuffled.iter().sum::<i32>(), 15);
1578    /// #     Ok(())
1579    /// # }
1580    /// ```
1581    #[cfg(feature = "postgres_backend")]
1582    fn array_shuffle<Arr: ArrayOrNullableArray + SingleValue>(array: Arr) -> Arr;
1583
1584    /// Returns an array of n items randomly selected from array.
1585    /// n may not exceed the length of the array.
1586    ///
1587    /// # Example
1588    // This function requires postgres >= 16.0
1589    // which we cannot expect to be widely used at the
1590    // point of writing this comment, so we skip running this test
1591    /// ```rust,no_run
1592    /// # include!("../../doctest_setup.rs");
1593    /// #
1594    /// # fn main() {
1595    /// #     run_test().unwrap();
1596    /// # }
1597    /// #
1598    /// # fn run_test() -> QueryResult<()> {
1599    /// #     use diesel::dsl::array_sample;
1600    /// #     use diesel::sql_types::{Array, Integer, Nullable};
1601    /// #     let connection = &mut establish_connection();
1602    ///
1603    /// let vec = vec![1, 2, 3, 4, 5];
1604    /// let sampled = diesel::select(array_sample::<Array<Integer>, _, _>(vec.clone(), 3))
1605    ///     .get_result::<Vec<i32>>(connection)?;
1606    /// assert_eq!(3, sampled.len());
1607    /// assert!(sampled.iter().all(|x| vec.contains(x)));
1608    ///
1609    /// let vec: Vec<i32> = Vec::new();
1610    /// let sampled = diesel::select(array_sample::<Array<Integer>, _, _>(vec, 0))
1611    ///     .get_result::<Vec<i32>>(connection)?;
1612    /// assert_eq!(0, sampled.len());
1613    ///
1614    /// let sampled = diesel::select(array_sample::<Nullable<Array<Integer>>, _, _>(
1615    ///     None::<Vec<i32>>,
1616    ///     1,
1617    /// ))
1618    /// .get_result::<Option<Vec<i32>>>(connection)?;
1619    /// assert!(sampled.is_none());
1620    /// #     Ok(())
1621    /// # }
1622    /// ```
1623    #[cfg(feature = "postgres_backend")]
1624    fn array_sample<Arr: ArrayOrNullableArray + SingleValue>(array: Arr, n: Integer) -> Arr;
1625
1626    /// Converts any Array to json.
1627    ///
1628    /// # Example
1629    ///
1630    /// ```rust
1631    /// # include!("../../doctest_setup.rs");
1632    /// #
1633    /// # fn main() {
1634    /// #     #[cfg(feature = "serde_json")]
1635    /// #     run_test().unwrap();
1636    /// # }
1637    /// #
1638    /// # #[cfg(feature = "serde_json")]
1639    /// # fn run_test() -> QueryResult<()> {
1640    /// #     use diesel::dsl::array_to_json;
1641    /// #     use diesel::sql_types::{Array, Integer, Text, Nullable};
1642    /// #     use serde_json::Value;
1643    /// #     let connection = &mut establish_connection();
1644    /// let json = diesel::select(array_to_json::<Array<Integer>, _>(vec![1, 2, 3, 4, 5]))
1645    ///     .get_result::<Value>(connection)?;
1646    /// let expected: Value = serde_json::json!([1, 2, 3, 4, 5]);
1647    /// assert_eq!(expected, json);
1648    /// let json = diesel::select(array_to_json::<Array<Text>, _>(vec![
1649    ///     "hello", "world", "John", "Doe",
1650    /// ]))
1651    /// .get_result::<Value>(connection)?;
1652    /// let expected: Value = serde_json::json!(["hello", "world", "John", "Doe"]);
1653    /// assert_eq!(expected, json);
1654    /// let empty: Vec<String> = Vec::new();
1655    /// let json = diesel::select(array_to_json::<Array<Nullable<Text>>, _>(empty))
1656    ///     .get_result::<Value>(connection)?;
1657    /// assert_eq!(serde_json::json!([]), json);
1658    /// let json = diesel::select(array_to_json::<Nullable<Array<Integer>>, _>(
1659    ///     None::<Vec<i32>>,
1660    /// ))
1661    /// .get_result::<Option<Value>>(connection)?;
1662    /// assert_eq!(None, json);
1663    /// #     Ok(())
1664    /// # }
1665    /// ```
1666    #[cfg(feature = "postgres_backend")]
1667    fn array_to_json<Arr: ArrayOrNullableArray + MaybeNullableValue<Json>>(array: Arr) -> Arr::Out;
1668
1669    /// Converts any SQL value to json
1670    ///
1671    /// # Example
1672    ///
1673    /// ```rust
1674    /// # include!("../../doctest_setup.rs");
1675    /// #
1676    /// # fn main() {
1677    /// #     #[cfg(feature = "serde_json")]
1678    /// #     run_test().unwrap();
1679    /// # }
1680    /// #
1681    /// # #[cfg(feature = "serde_json")]
1682    /// # fn run_test() -> QueryResult<()> {
1683    /// #     use diesel::dsl::to_json;
1684    /// #     use serde_json::{json, Value};
1685    /// #     use diesel::sql_types::{Integer, Array, Json, Text, Nullable};
1686    /// #     let connection = &mut establish_connection();
1687    /// let result = diesel::select(to_json::<Integer, _>(1)).get_result::<Value>(connection)?;
1688    ///
1689    /// assert_eq!(json!(1), result);
1690    ///
1691    /// let result = diesel::select(to_json::<Array<Text>, _>(vec!["abc", "xyz"]))
1692    ///     .get_result::<Value>(connection)?;
1693    ///
1694    /// assert_eq!(json!(["abc", "xyz"]), result);
1695    ///
1696    /// let result = diesel::select(to_json::<Array<Nullable<Text>>, _>(Vec::<String>::new()))
1697    ///     .get_result::<Value>(connection)?;
1698    ///
1699    /// assert_eq!(json!([]), result);
1700    ///
1701    /// let result = diesel::select(to_json::<Nullable<Text>, _>(None::<String>))
1702    ///     .get_result::<Option<Value>>(connection)?;
1703    ///
1704    /// assert!(result.is_none());
1705    ///
1706    /// #     Ok(())
1707    /// # }
1708    /// ```
1709    #[cfg(feature = "postgres_backend")]
1710    fn to_json<E: MaybeNullableValue<Json>>(e: E) -> E::Out;
1711
1712    /// Converts any SQL value to jsonb
1713    ///
1714    /// # Example
1715    ///
1716    /// ```rust
1717    /// # include!("../../doctest_setup.rs");
1718    /// #
1719    /// # fn main() {
1720    /// #     #[cfg(feature = "serde_json")]
1721    /// #     run_test().unwrap();
1722    /// # }
1723    /// #
1724    /// # #[cfg(feature = "serde_json")]
1725    /// # fn run_test() -> QueryResult<()> {
1726    /// #     use diesel::dsl::to_jsonb;
1727    /// #     use serde_json::{json, Value};
1728    /// #     use diesel::sql_types::{Integer, Array, Jsonb, Text, Nullable};
1729    /// #     let connection = &mut establish_connection();
1730    /// let result = diesel::select(to_jsonb::<Integer, _>(1)).get_result::<Value>(connection)?;
1731    ///
1732    /// assert_eq!(json!(1), result);
1733    ///
1734    /// let result = diesel::select(to_jsonb::<Array<Text>, _>(vec!["abc", "def"]))
1735    ///     .get_result::<Value>(connection)?;
1736    ///
1737    /// assert_eq!(json!(["abc", "def"]), result);
1738    ///
1739    /// let result = diesel::select(to_jsonb::<Array<Nullable<Text>>, _>(Vec::<String>::new()))
1740    ///     .get_result::<Value>(connection)?;
1741    ///
1742    /// assert_eq!(json!([]), result);
1743    ///
1744    /// let result = diesel::select(to_jsonb::<Nullable<Text>, _>(None::<String>))
1745    ///     .get_result::<Option<Value>>(connection)?;
1746    ///
1747    /// assert!(result.is_none());
1748    ///
1749    /// #     Ok(())
1750    /// # }
1751    /// ```
1752    #[cfg(feature = "postgres_backend")]
1753    fn to_jsonb<E: MaybeNullableValue<Jsonb>>(e: E) -> E::Out;
1754
1755    /// Builds a JSON object out of a text array. The array must have an even number of members,
1756    /// in which case they are taken as alternating key/value pairs
1757    ///
1758    /// # Example
1759    ///
1760    /// ```rust
1761    /// # include!("../../doctest_setup.rs");
1762    /// #
1763    /// # fn main() {
1764    /// #     #[cfg(feature = "serde_json")]
1765    /// #     run_test().unwrap();
1766    /// # }
1767    /// #
1768    /// # #[cfg(feature = "serde_json")]
1769    /// # fn run_test() -> QueryResult<()> {
1770    /// #     use diesel::dsl::json_object;
1771    /// #     use diesel::sql_types::{Array, Json, Nullable, Text};
1772    /// #     use serde_json::Value;
1773    /// #     let connection = &mut establish_connection();
1774    /// let json = diesel::select(json_object::<Array<Text>,_>(vec!["hello","world"]))
1775    ///                 .get_result::<Value>(connection)?;
1776    /// let expected:Value = serde_json::json!({"hello":"world"});
1777    /// assert_eq!(expected,json);
1778    ///
1779    /// let json = diesel::select(json_object::<Array<Text>,_>(vec!["hello","world","John","Doe"]))
1780    ///                 .get_result::<Value>(connection)?;
1781    /// let expected:Value = serde_json::json!({"hello":"world","John":"Doe"});
1782    /// assert_eq!(expected,json);
1783    ///
1784    /// let json = diesel::select(json_object::<Array<Text>,_>(vec!["hello","world","John"]))
1785    ///                 .get_result::<Value>(connection);
1786    /// assert!(json.is_err());
1787    ///
1788    /// let empty:Vec<String> = Vec::new();
1789    /// let json = diesel::select(json_object::<Array<Nullable<Text>>,_>(empty))
1790    ///                 .get_result::<Value>(connection);
1791    /// assert!(json.is_err());
1792    ///
1793    /// #     Ok(())
1794    /// # }
1795    /// ```
1796    #[cfg(feature = "postgres_backend")]
1797    fn json_object<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Json>>(
1798        text_array: Arr,
1799    ) -> Arr::Out;
1800
1801    /// This form of json_object takes keys and values pairwise from two separate arrays.
1802    /// In all other respects it is identical to the one-argument form.
1803    ///
1804    /// # Example
1805    ///
1806    /// ```rust
1807    /// # include!("../../doctest_setup.rs");
1808    /// #
1809    /// # fn main() {
1810    /// #     #[cfg(feature = "serde_json")]
1811    /// #     run_test().unwrap();
1812    /// # }
1813    /// #
1814    /// # #[cfg(feature = "serde_json")]
1815    /// # fn run_test() -> QueryResult<()> {
1816    /// #     use diesel::dsl::json_object_with_keys_and_values;
1817    /// #     use diesel::sql_types::{Array, Json, Nullable, Text};
1818    /// #     use serde_json::Value;
1819    /// #     let connection = &mut establish_connection();
1820    /// let json = diesel::select(json_object_with_keys_and_values::<Array<Text>, Array<Text>, _, _>(
1821    ///             vec!["hello","John"],vec!["world","Doe"]))
1822    ///             .get_result::<Value>(connection)?;
1823    /// let expected:Value = serde_json::json!({"hello":"world","John":"Doe"});
1824    /// assert_eq!(expected,json);
1825    ///
1826    /// let json = diesel::select(json_object_with_keys_and_values::<Nullable<Array<Text>>, Nullable<Array<Text>>, _, _>(
1827    ///             Some(vec!["hello","John"]), None::<Vec<String>>))
1828    ///             .get_result::<Option<Value>>(connection)?;
1829    /// assert_eq!(None::<Value>,json);
1830    ///
1831    /// let empty: Vec<String> = Vec::new();
1832    /// let json = diesel::select(json_object_with_keys_and_values::<Array<Text>, Array<Text>, _, _>(
1833    ///             vec!["hello","John"], empty))
1834    ///             .get_result::<Value>(connection);
1835    /// assert!(json.is_err());
1836    ///
1837    /// #     Ok(())
1838    /// # }
1839    /// ```
1840    #[sql_name = "json_object"]
1841    #[cfg(feature = "postgres_backend")]
1842    fn json_object_with_keys_and_values<
1843        Arr1: TextArrayOrNullableTextArray + SingleValue,
1844        Arr2: TextArrayOrNullableTextArray + CombinedNullableValue<Arr1, Json>,
1845    >(
1846        keys: Arr1,
1847        values: Arr2,
1848    ) -> Arr2::Out;
1849
1850    /// Returns the type of the top-level json value as a text-string
1851    ///
1852    /// # Example
1853    ///
1854    /// ```rust
1855    /// # include!("../../doctest_setup.rs");
1856    /// #
1857    /// # fn main() {
1858    /// #     #[cfg(feature = "serde_json")]
1859    /// #     run_test().unwrap();
1860    /// # }
1861    /// #
1862    /// # #[cfg(feature = "serde_json")]
1863    /// # fn run_test() -> QueryResult<()> {
1864    /// #     use diesel::dsl::json_typeof;
1865    /// #     use serde_json::{json, Value};
1866    /// #     use diesel::sql_types::{Json, Nullable};
1867    /// #     let connection = &mut establish_connection();
1868    /// let result = diesel::select(json_typeof::<Json, _>(json!({"a": "b", "c": 1})))
1869    ///     .get_result::<String>(connection)?;
1870    ///
1871    /// assert_eq!("object".to_string(), result);
1872    ///
1873    /// let result = diesel::select(json_typeof::<Json, _>(json!([1,2,3])))
1874    ///     .get_result::<String>(connection)?;
1875    ///
1876    /// assert_eq!("array".to_string(), result);
1877    ///
1878    /// let result = diesel::select(json_typeof::<Json, _>(json!("abc")))
1879    ///     .get_result::<String>(connection)?;
1880    ///
1881    /// assert_eq!("string".to_string(), result);
1882    ///
1883    /// let result = diesel::select(json_typeof::<Json, _>(json!(-123.4)))
1884    ///     .get_result::<String>(connection)?;
1885    ///
1886    /// assert_eq!("number".to_string(), result);
1887    ///
1888    /// let result = diesel::select(json_typeof::<Json, _>(json!(true)))
1889    ///     .get_result::<String>(connection)?;
1890    ///
1891    /// assert_eq!("boolean".to_string(), result);
1892    ///
1893    /// let result = diesel::select(json_typeof::<Json, _>(json!(null)))
1894    ///     .get_result::<String>(connection)?;
1895    ///
1896    /// assert_eq!("null".to_string(), result);
1897    ///
1898    /// let result = diesel::select(json_typeof::<Nullable<Json>, _>(None::<Value>))
1899    ///     .get_result::<Option<String>>(connection)?;
1900    ///
1901    /// assert!(result.is_none());
1902    /// #     Ok(())
1903    /// # }
1904    /// ```
1905    #[cfg(feature = "postgres_backend")]
1906    fn json_typeof<E: JsonOrNullableJson + SingleValue + MaybeNullableValue<Text>>(e: E) -> E::Out;
1907
1908    /// Returns the type of the top-level jsonb value as a text-string
1909    ///
1910    /// # Example
1911    ///
1912    /// ```rust
1913    /// # include!("../../doctest_setup.rs");
1914    /// #
1915    /// # fn main() {
1916    /// #     #[cfg(feature = "serde_json")]
1917    /// #     run_test().unwrap();
1918    /// # }
1919    /// #
1920    /// # #[cfg(feature = "serde_json")]
1921    /// # fn run_test() -> QueryResult<()> {
1922    /// #     use diesel::dsl::jsonb_typeof;
1923    /// #     use serde_json::{json, Value};
1924    /// #     use diesel::sql_types::{Jsonb, Nullable};
1925    /// #     let connection = &mut establish_connection();
1926    /// let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!({"a": "b", "c": 1})))
1927    ///     .get_result::<String>(connection)?;
1928    ///
1929    /// assert_eq!("object".to_string(), result);
1930    ///
1931    /// let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!([1,2,3])))
1932    ///     .get_result::<String>(connection)?;
1933    ///
1934    /// assert_eq!("array".to_string(), result);
1935    ///
1936    /// let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!("abc")))
1937    ///     .get_result::<String>(connection)?;
1938    ///
1939    /// assert_eq!("string".to_string(), result);
1940    ///
1941    /// let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!(-123.4)))
1942    ///     .get_result::<String>(connection)?;
1943    ///
1944    /// assert_eq!("number".to_string(), result);
1945    ///
1946    /// let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!(true)))
1947    ///     .get_result::<String>(connection)?;
1948    ///
1949    /// assert_eq!("boolean".to_string(), result);
1950    ///
1951    /// let result = diesel::select(jsonb_typeof::<Jsonb, _>(json!(null)))
1952    ///     .get_result::<String>(connection)?;
1953    ///
1954    /// assert_eq!("null".to_string(), result);
1955    ///
1956    /// let result = diesel::select(jsonb_typeof::<Nullable<Jsonb>, _>(None::<Value>))
1957    ///     .get_result::<Option<String>>(connection)?;
1958    ///
1959    /// assert!(result.is_none());
1960    /// #     Ok(())
1961    /// # }
1962    /// ```
1963    #[cfg(feature = "postgres_backend")]
1964    fn jsonb_typeof<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>>(
1965        e: E,
1966    ) -> E::Out;
1967
1968    /// Converts the given json value to pretty-printed, indented text
1969    ///
1970    /// # Example
1971    ///
1972    /// ```rust
1973    /// # include!("../../doctest_setup.rs");
1974    /// #
1975    /// # fn main() {
1976    /// #     #[cfg(feature = "serde_json")]
1977    /// #     run_test().unwrap();
1978    /// # }
1979    /// #
1980    /// # #[cfg(feature = "serde_json")]
1981    /// # fn run_test() -> QueryResult<()> {
1982    /// #     use diesel::dsl::jsonb_pretty;
1983    /// #     use serde_json::{json, Value};
1984    /// #     use diesel::sql_types::{Jsonb, Nullable};
1985    /// #     let connection = &mut establish_connection();
1986    /// let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!([{"f1":1,"f2":null},2,null,3])))
1987    ///     .get_result::<String>(connection)?;
1988    ///
1989    /// assert_eq!(r#"[
1990    ///     {
1991    ///         "f1": 1,
1992    ///         "f2": null
1993    ///     },
1994    ///     2,
1995    ///     null,
1996    ///     3
1997    /// ]"#, result);
1998    ///
1999    /// let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!({"a": 1, "b": "cd"})))
2000    ///     .get_result::<String>(connection)?;
2001    ///
2002    /// assert_eq!(r#"{
2003    ///     "a": 1,
2004    ///     "b": "cd"
2005    /// }"#, result);
2006    ///
2007    /// let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!("abc")))
2008    ///     .get_result::<String>(connection)?;
2009    ///
2010    /// assert_eq!(r#""abc""#, result);
2011    ///
2012    /// let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!(22)))
2013    ///     .get_result::<String>(connection)?;
2014    ///
2015    /// assert_eq!(r#"22"#, result);
2016    ///
2017    /// let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!(false)))
2018    ///     .get_result::<String>(connection)?;
2019    ///
2020    /// assert_eq!(r#"false"#, result);
2021    ///
2022    /// let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!(null)))
2023    ///     .get_result::<String>(connection)?;
2024    ///
2025    /// assert_eq!(r#"null"#, result);
2026    ///
2027    /// let result = diesel::select(jsonb_pretty::<Jsonb, _>(json!({})))
2028    ///     .get_result::<String>(connection)?;
2029    ///
2030    /// assert_eq!(r#"{
2031    /// }"#, result);
2032    ///
2033    /// let result = diesel::select(jsonb_pretty::<Nullable<Jsonb>, _>(None::<Value>))
2034    ///     .get_result::<Option<String>>(connection)?;
2035    ///
2036    /// assert!(result.is_none());
2037    /// #     Ok(())
2038    /// # }
2039    /// ```
2040    #[cfg(feature = "postgres_backend")]
2041    fn jsonb_pretty<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>>(
2042        e: E,
2043    ) -> E::Out;
2044
2045    /// Deletes all object fields that have null values from the given JSON value, recursively.
2046    ///
2047    /// # Example
2048    ///
2049    /// ```rust
2050    /// # include!("../../doctest_setup.rs");
2051    /// #
2052    /// # fn main() {
2053    /// #     #[cfg(feature = "serde_json")]
2054    /// #     run_test().unwrap();
2055    /// # }
2056    /// #
2057    /// # #[cfg(feature = "serde_json")]
2058    /// # fn run_test() -> QueryResult<()> {
2059    /// #     use diesel::dsl::json_strip_nulls;
2060    /// #     use diesel::sql_types::{Json, Nullable};
2061    /// #     use serde_json::{json, Value};
2062    /// #     let connection = &mut establish_connection();
2063    ///
2064    /// let result = diesel::select(json_strip_nulls::<Json, _>(json!({"hello": null})))
2065    ///     .get_result::<Value>(connection)?;
2066    /// let expected: Value = json!({});
2067    /// assert_eq!(result, expected);
2068    ///
2069    /// let result = diesel::select(json_strip_nulls::<Json, _>(json!([{"f1":1, "f2":null}, 2, null, 3])))
2070    ///     .get_result::<Value>(connection)?;
2071    /// let expected: Value = json!([{"f1":1}, 2, null, 3]);
2072    /// assert_eq!(result, expected);
2073    ///
2074    /// let result = diesel::select(json_strip_nulls::<Nullable<Json>, _>(None::<Value>))
2075    ///     .get_result::<Option<Value>>(connection)?;
2076    /// assert!(result.is_none());
2077    ///
2078    /// let result = diesel::select(json_strip_nulls::<Json, _>(json!(null)))
2079    ///     .get_result::<Value>(connection)?;
2080    /// let expected = json!(null);
2081    /// assert_eq!(result, expected);
2082    ///
2083    ///
2084    /// #     Ok(())
2085    /// # }
2086    /// ```
2087    #[cfg(feature = "postgres_backend")]
2088    fn json_strip_nulls<E: JsonOrNullableJson + SingleValue>(json: E) -> E;
2089
2090    /// Deletes all object fields that have null values from the given JSON value, recursively.
2091    ///
2092    /// # Example
2093    ///
2094    /// ```rust
2095    /// # include!("../../doctest_setup.rs");
2096    /// #
2097    /// # fn main() {
2098    /// #     #[cfg(feature = "serde_json")]
2099    /// #     run_test().unwrap();
2100    /// # }
2101    /// #
2102    /// # #[cfg(feature = "serde_json")]
2103    /// # fn run_test() -> QueryResult<()> {
2104    /// #     use diesel::dsl::jsonb_strip_nulls;
2105    /// #     use diesel::sql_types::{Jsonb, Nullable};
2106    /// #     use serde_json::{json, Value};
2107    /// #     let connection = &mut establish_connection();
2108    ///
2109    /// let result = diesel::select(jsonb_strip_nulls::<Jsonb, _>(json!({"hello": null})))
2110    ///     .get_result::<Value>(connection)?;
2111    /// let expected: Value = json!({});
2112    /// assert_eq!(result, expected);
2113    ///
2114    /// let result = diesel::select(jsonb_strip_nulls::<Jsonb, _>(json!([{"f1":1, "f2":null}, 2, null, 3])))
2115    ///     .get_result::<Value>(connection)?;
2116    /// let expected: Value = json!([{"f1":1}, 2, null, 3]);
2117    /// assert_eq!(result, expected);
2118    ///
2119    /// let result = diesel::select(jsonb_strip_nulls::<Nullable<Jsonb>, _>(None::<Value>))
2120    ///     .get_result::<Option<Value>>(connection)?;
2121    /// assert!(result.is_none());
2122    ///
2123    /// let result = diesel::select(jsonb_strip_nulls::<Jsonb, _>(json!(null)))
2124    ///     .get_result::<Value>(connection)?;
2125    /// let expected = json!(null);
2126    /// assert_eq!(result, expected);
2127    ///
2128    ///
2129    ///
2130    /// #     Ok(())
2131    /// # }
2132    /// ```
2133    #[cfg(feature = "postgres_backend")]
2134    fn jsonb_strip_nulls<E: JsonbOrNullableJsonb + SingleValue>(jsonb: E) -> E;
2135
2136    /// Returns the number of elements in the top-level JSON array
2137    ///
2138    ///
2139    /// # Example
2140    ///
2141    /// ```rust
2142    /// # include!("../../doctest_setup.rs");
2143    /// #
2144    /// # fn main() {
2145    /// #     #[cfg(feature = "serde_json")]
2146    /// #     run_test().unwrap();
2147    /// # }
2148    /// #
2149    /// # #[cfg(feature = "serde_json")]
2150    /// # fn run_test() -> QueryResult<()> {
2151    /// #     use diesel::dsl::json_array_length;
2152    /// #     use serde_json::{json, Value};
2153    /// #     use diesel::sql_types::{Integer, Json, Nullable};
2154    /// #     let connection = &mut establish_connection();
2155    ///
2156    /// let result = diesel::select(json_array_length::<Json, _>(json!([1, 2, 3])))
2157    ///     .get_result::<i32>(connection)?;
2158    /// assert_eq!(result, 3);
2159    ///
2160    /// let result =
2161    ///     diesel::select(json_array_length::<Json, _>(json!([]))).get_result::<i32>(connection)?;
2162    /// assert_eq!(result, 0);
2163    ///
2164    /// let result = diesel::select(json_array_length::<Nullable<Json>, _>(None::<Value>))
2165    ///     .get_result::<Option<i32>>(connection)?;
2166    /// assert!(result.is_none());
2167    ///
2168    /// #     Ok(())
2169    /// # }
2170    /// ```
2171    #[cfg(feature = "postgres_backend")]
2172    fn json_array_length<E: JsonOrNullableJson + MaybeNullableValue<Integer>>(json: E) -> E::Out;
2173
2174    /// Returns the number of elements in the top-level JSON array
2175    ///
2176    ///
2177    /// # Example
2178    ///
2179    /// ```rust
2180    /// # include!("../../doctest_setup.rs");
2181    /// #
2182    /// # fn main() {
2183    /// #     #[cfg(feature = "serde_json")]
2184    /// #     run_test().unwrap();
2185    /// # }
2186    /// #
2187    /// # #[cfg(feature = "serde_json")]
2188    /// # fn run_test() -> QueryResult<()> {
2189    /// #     use diesel::dsl::jsonb_array_length;
2190    /// #     use serde_json::{json, Value};
2191    /// #     use diesel::sql_types::{Integer, Jsonb, Nullable};
2192    /// #     let connection = &mut establish_connection();
2193    ///
2194    /// let result = diesel::select(jsonb_array_length::<Jsonb, _>(json!([1, 2, 3])))
2195    ///     .get_result::<i32>(connection)?;
2196    /// assert_eq!(result, 3);
2197    ///
2198    /// let result =
2199    ///     diesel::select(jsonb_array_length::<Jsonb, _>(json!([]))).get_result::<i32>(connection)?;
2200    /// assert_eq!(result, 0);
2201    ///
2202    /// let result = diesel::select(jsonb_array_length::<Nullable<Jsonb>, _>(None::<Value>))
2203    ///     .get_result::<Option<i32>>(connection)?;
2204    /// assert!(result.is_none());
2205    ///
2206    /// #     Ok(())
2207    /// # }
2208    /// ```
2209    #[cfg(feature = "postgres_backend")]
2210    fn jsonb_array_length<E: JsonbOrNullableJsonb + MaybeNullableValue<Integer>>(
2211        jsonb: E,
2212    ) -> E::Out;
2213    /// Builds a JSON object out of a text array. The array must have an even number of members,
2214    /// in which case they are taken as alternating key/value pairs. This function also has a form that
2215    /// that takes keys and values as separate text array arguments.
2216    /// See [jsonb_object_with_keys_and_values](jsonb_object_with_keys_and_values())
2217    ///
2218    /// # Example
2219    ///
2220    /// ```rust
2221    /// # include!("../../doctest_setup.rs");
2222    /// #
2223    /// # fn main() {
2224    /// #     #[cfg(feature = "serde_json")]
2225    /// #     run_test().unwrap();
2226    /// # }
2227    /// #
2228    /// # #[cfg(feature = "serde_json")]
2229    /// # fn run_test() -> QueryResult<()> {
2230    /// #     use diesel::dsl::jsonb_object;
2231    /// #     use diesel::sql_types::{Array, Json, Nullable, Text};
2232    /// #     use serde_json::Value;
2233    /// #     let connection = &mut establish_connection();
2234    /// let jsonb = diesel::select(jsonb_object::<Array<Text>,_>(vec!["hello","world"]))
2235    ///                 .get_result::<Value>(connection)?;
2236    /// let expected:Value = serde_json::json!({"hello":"world"});
2237    /// assert_eq!(expected, jsonb);
2238    ///
2239    /// let jsonb = diesel::select(jsonb_object::<Array<Text>, _>(vec!["hello","world","John","Doe"]))
2240    ///                 .get_result::<Value>(connection)?;
2241    /// let expected:Value = serde_json::json!({"hello": "world","John": "Doe"});
2242    /// assert_eq!(expected, jsonb);
2243    ///
2244    /// let jsonb = diesel::select(jsonb_object::<Nullable<Array<Text>>, _>(None::<Vec<String>>))
2245    ///                 .get_result::<Option<Value>>(connection)?;
2246    /// assert!(jsonb.is_none());
2247    ///
2248    /// let empty:Vec<String> = Vec::new();
2249    /// let jsonb = diesel::select(jsonb_object::<Array<Nullable<Text>>,_>(empty))
2250    ///                 .get_result::<Value>(connection)?;
2251    /// let expected = serde_json::json!({});
2252    /// assert_eq!(expected, jsonb);
2253    ///
2254    /// let jsonb = diesel::select(jsonb_object::<Array<Text>, _>(vec!["hello","world","John"]))
2255    ///                 .get_result::<Value>(connection);
2256    /// assert!(jsonb.is_err());
2257    ///
2258    ///
2259    /// #     Ok(())
2260    /// # }
2261    /// ```
2262    #[cfg(feature = "postgres_backend")]
2263    fn jsonb_object<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Jsonb>>(
2264        text_array: Arr,
2265    ) -> Arr::Out;
2266
2267    /// This form of jsonb_object takes keys and values pairwise from two separate arrays.
2268    /// In all other respects it is identical to the one-argument form.
2269    ///
2270    /// # Example
2271    ///
2272    /// ```rust
2273    /// # include!("../../doctest_setup.rs");
2274    /// #
2275    /// # fn main() {
2276    /// #     #[cfg(feature = "serde_json")]
2277    /// #     run_test().unwrap();
2278    /// # }
2279    /// #
2280    /// # #[cfg(feature = "serde_json")]
2281    /// # fn run_test() -> QueryResult<()> {
2282    /// #     use diesel::dsl::jsonb_object_with_keys_and_values;
2283    /// #     use diesel::sql_types::{Array, Nullable, Text};
2284    /// #     use serde_json::Value;
2285    /// #     let connection = &mut establish_connection();
2286    /// let jsonb = diesel::select(jsonb_object_with_keys_and_values::<Array<Text>, Array<Text>, _, _>(
2287    ///             vec!["hello","John"],vec!["world","Doe"]))
2288    ///             .get_result::<Value>(connection)?;
2289    /// let expected:Value = serde_json::json!({"hello":"world","John":"Doe"});
2290    /// assert_eq!(expected, jsonb);
2291    ///
2292    /// let jsonb = diesel::select(jsonb_object_with_keys_and_values::<Nullable<Array<Text>>, Nullable<Array<Text>>, _, _>(
2293    ///             Some(vec!["hello","John"]),None::<Vec<String>>))
2294    ///             .get_result::<Option<Value>>(connection)?;
2295    /// assert_eq!(None::<Value>,jsonb);
2296    ///
2297    /// let empty: Vec<String> = Vec::new();
2298    /// let jsonb = diesel::select(jsonb_object_with_keys_and_values::<Array<Text>, Array<Text>, _, _>(
2299    ///             vec!["hello","John"],empty))
2300    ///             .get_result::<Value>(connection);
2301    /// assert!(jsonb.is_err());
2302    ///
2303    /// #     Ok(())
2304    /// # }
2305    /// ```
2306    #[sql_name = "jsonb_object"]
2307    #[cfg(feature = "postgres_backend")]
2308    fn jsonb_object_with_keys_and_values<
2309        Arr1: TextArrayOrNullableTextArray + SingleValue,
2310        Arr2: TextArrayOrNullableTextArray + CombinedNullableValue<Arr1, Jsonb>,
2311    >(
2312        keys: Arr1,
2313        values: Arr2,
2314    ) -> Arr2::Out;
2315
2316    /// This function `row_to_json` takes a Record type as an input and converts it to JSON.
2317    ///
2318    /// # Example
2319    ///
2320    /// ```rust
2321    /// # include!("../../doctest_setup.rs");
2322    /// #
2323    /// # fn main() {
2324    /// #     #[cfg(feature = "serde_json")]
2325    /// #     run_test().unwrap();
2326    /// # }
2327    /// #
2328    /// # #[cfg(feature = "serde_json")]
2329    /// # fn run_test() -> QueryResult<()> {
2330    /// #     use diesel::dsl::row_to_json;
2331    /// #     use diesel::dsl::sql;
2332    /// #     use diesel::sql_types::{Record, Text, Integer};
2333    /// #     use serde_json::Value;
2334    /// #     let connection = &mut establish_connection();
2335    ///
2336    /// let json_value = diesel::select(row_to_json(sql::<Record<(Text, Integer)>>(
2337    ///     "ROW('John', 30)"
2338    /// )))
2339    /// .get_result::<Value>(connection)?;
2340    /// let expected: Value = serde_json::json!({
2341    ///     "f1": "John",
2342    ///     "f2": 30
2343    /// });
2344    /// assert_eq!(expected, json_value);
2345    ///
2346    /// let json_value = diesel::select(row_to_json(sql::<Record<()>>("ROW()")))
2347    /// .get_result::<Value>(connection)?;
2348    /// let expected: Value = serde_json::json!({});
2349    /// assert_eq!(expected, json_value);
2350    ///
2351    /// #    Ok(())
2352    /// # }
2353    /// ```
2354    #[sql_name = "row_to_json"]
2355    #[cfg(feature = "postgres_backend")]
2356    fn row_to_json<R: RecordOrNullableRecord + MaybeNullableValue<Json>>(record: R) -> R::Out;
2357
2358    /// This function `json_populate_record` takes a Record base and Json as an input and converts it to top-level
2359    /// JSON object to a row having the composite type of the base argument.
2360    ///
2361    /// # Example
2362    ///
2363    /// ```rust
2364    /// # include!("../../doctest_setup.rs");
2365    /// #
2366    /// # fn main() {
2367    /// #     #[cfg(feature = "serde_json")]
2368    /// #     run_test().unwrap();
2369    /// # }
2370    /// #
2371    /// # #[cfg(feature = "serde_json")]
2372    /// # fn run_test() -> QueryResult<()> {
2373    /// #     use diesel::dsl::json_populate_record;
2374    /// #     use diesel::dsl::sql;
2375    /// #     use diesel::sql_types::{Record, Text, Integer, Json};
2376    /// #     use serde_json::Value;
2377    /// #     let connection = &mut establish_connection();
2378    ///
2379    /// let expected: Value = serde_json::json!({
2380    ///     "f1": "Alice",
2381    ///     "f2": 16
2382    /// });
2383    /// let record: (String, i32) = diesel::select(json_populate_record::<Record<(Text, Integer)>, Json, _, _>(
2384    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
2385    ///         expected
2386    /// )).get_result(connection)?;
2387    /// assert_eq!(record, ("Alice".to_string(), 16));
2388    ///
2389    /// let expected: Value = serde_json::json!({});
2390    /// let record: (String, i32) = diesel::select(json_populate_record::<Record<(Text, Integer)>, Json, _, _>(
2391    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
2392    ///         expected
2393    /// )).get_result(connection)?;
2394    /// assert_eq!(record, ("John".to_string(), 30));
2395    ///
2396    /// let expected: Value = serde_json::json!({
2397    ///     "f1": "Alice"
2398    /// });
2399    /// let record: (String, i32) = diesel::select(json_populate_record::<Record<(Text, Integer)>, Json, _, _>(
2400    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
2401    ///         expected
2402    /// )).get_result(connection)?;
2403    /// assert_eq!(record, ("Alice".to_string(), 30));
2404    ///
2405    /// #    Ok(())
2406    /// # }
2407    /// ```
2408    #[sql_name = "json_populate_record"]
2409    #[cfg(feature = "postgres_backend")]
2410    fn json_populate_record<
2411        B: RecordOrNullableRecord + SingleValue,
2412        J: JsonOrNullableJson + CombinedAllNullableValue<Json, B>,
2413    >(
2414        base: B,
2415        from_json: J,
2416    ) -> J::Out;
2417
2418    /// This function `jsonb_populate_record` takes a Record base and Jsonb as an input and converts it to top-level
2419    /// JSON object to a row having the composite type of the base argument.
2420    ///
2421    /// # Example
2422    ///
2423    /// ```rust
2424    /// # include!("../../doctest_setup.rs");
2425    /// #
2426    /// # fn main() {
2427    /// #     #[cfg(feature = "serde_json")]
2428    /// #     run_test().unwrap();
2429    /// # }
2430    /// #
2431    /// # #[cfg(feature = "serde_json")]
2432    /// # fn run_test() -> QueryResult<()> {
2433    /// #     use diesel::dsl::jsonb_populate_record;
2434    /// #     use diesel::dsl::sql;
2435    /// #     use diesel::sql_types::{Record, Text, Integer, Jsonb};
2436    /// #     use serde_json::Value;
2437    /// #     let connection = &mut establish_connection();
2438    ///
2439    /// let expected: Value = serde_json::json!({
2440    ///     "f1": "Alice",
2441    ///     "f2": 16
2442    /// });
2443    /// let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>(
2444    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
2445    ///         expected
2446    /// )).get_result(connection)?;
2447    /// assert_eq!(record, ("Alice".to_string(), 16));
2448    ///
2449    /// let expected: Value = serde_json::json!({});
2450    /// let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>(
2451    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
2452    ///         expected
2453    /// )).get_result(connection)?;
2454    /// assert_eq!(record, ("John".to_string(), 30));
2455    ///
2456    /// let expected: Value = serde_json::json!({
2457    ///     "f2": 42,
2458    /// });
2459    /// let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>(
2460    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
2461    ///         expected
2462    /// )).get_result(connection)?;
2463    /// assert_eq!(record, ("John".to_string(), 42));
2464    ///
2465    /// #    Ok(())
2466    /// # }
2467    /// ```
2468    #[sql_name = "jsonb_populate_record"]
2469    #[cfg(feature = "postgres_backend")]
2470    fn jsonb_populate_record<
2471        B: RecordOrNullableRecord + SingleValue,
2472        J: JsonbOrNullableJsonb + CombinedAllNullableValue<Jsonb, B>,
2473    >(
2474        base: B,
2475        from_json: J,
2476    ) -> J::Out;
2477
2478    /// Returns target with the item designated by path replaced by new_value,
2479    ///     or with new_value added and the item designated by path does not exist.
2480    ///
2481    /// It can't set path in scalar
2482    ///
2483    /// All earlier steps in the path must exist, or the target is returned unchanged.
2484    /// As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays.
2485    /// If the last path step is an array index that is out of range,
2486    ///    the new value is added at the beginning of the array if the index is negative,
2487    ///     or at the end of the array if it is positive.
2488    ///
2489    /// # Example
2490    ///
2491    /// ```rust
2492    /// # include!("../../doctest_setup.rs");
2493    /// #
2494    /// # fn main() {
2495    /// #     #[cfg(feature = "serde_json")]
2496    /// #     run_test().unwrap();
2497    /// # }
2498    /// #
2499    /// # #[cfg(feature = "serde_json")]
2500    /// # fn run_test() -> QueryResult<()> {
2501    /// #     use diesel::dsl::jsonb_set;
2502    /// #     use diesel::sql_types::{Jsonb,Array, Json, Nullable, Text};
2503    /// #     use serde_json::{json,Value};
2504    /// #     let connection = &mut establish_connection();
2505    ///
2506    /// let result = diesel::select(jsonb_set::<Jsonb, Array<Text>, _, _, _>(
2507    ///         json!([{"f1":1,"f2":null},2,null,3]),
2508    ///         vec!["0","f1"],
2509    ///         json!([2,3,4])
2510    ///     )).get_result::<Value>(connection)?;
2511    /// let expected: Value = json!([{"f1": [2, 3, 4], "f2": null}, 2, null, 3]);
2512    /// assert_eq!(result, expected);
2513    ///
2514    /// let result = diesel::select(jsonb_set::<Jsonb, Array<Text>, _, _, _>(
2515    ///         json!([{"odd":[2,4,6,8]}]),
2516    ///         // not vec!["odd"], cannot set path in scalar
2517    ///         vec!["0","odd"],
2518    ///         json!([1,3,5,7])
2519    ///     )).get_result::<Value>(connection)?;
2520    /// let expected: Value = json!([{"odd":[1,3,5,7]}]);
2521    /// assert_eq!(result, expected);
2522    ///
2523    /// let empty:Vec<String> = Vec::new();
2524    /// let result = diesel::select(jsonb_set::<Nullable<Jsonb>, Array<Nullable<Text>>, _, _, _>(
2525    ///         None::<Value>,
2526    ///         empty,
2527    ///         None::<Value>
2528    ///     )).get_result::<Option<Value>>(connection)?;
2529    /// assert!(result.is_none());
2530    ///
2531    /// let empty:Vec<String> = Vec::new();
2532    /// let result = diesel::select(jsonb_set::<Jsonb, Array<Nullable<Text>>, _, _, _>(
2533    ///         // cannot be json!(null)
2534    ///         json!([]),
2535    ///         empty,
2536    ///         json!(null)
2537    ///     )).get_result::<Value>(connection)?;
2538    /// let expected = json!([]);
2539    /// assert_eq!(result, expected);
2540    ///
2541    /// let result = diesel::select(jsonb_set::<Jsonb, Nullable<Array<Nullable<Text>>>, _, _, _,>(
2542    ///         json!(null),
2543    ///         None::<Vec<String>>,
2544    ///         json!({"foo": 42})
2545    ///     )).get_result::<Option<Value>>(connection)?;
2546    /// assert!(result.is_none());
2547    ///
2548    ///
2549    /// #     Ok(())
2550    /// # }
2551    /// ```
2552    #[cfg(feature = "postgres_backend")]
2553    fn jsonb_set<
2554        E: JsonbOrNullableJsonb + SingleValue,
2555        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2556    >(
2557        base: E,
2558        path: Arr,
2559        new_value: E,
2560    ) -> Arr::Out;
2561
2562    /// Returns target with the item designated by path replaced by new_value,
2563    ///     or with new_value added if create_if_missing is true (which is the default)
2564    ///     and the item designated by path does not exist.
2565    ///
2566    /// It can't set path in scalar
2567    ///
2568    /// All earlier steps in the path must exist, or the target is returned unchanged.
2569    /// As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays.
2570    /// If the last path step is an array index that is out of range,
2571    ///     and create_if_missing is true, the new value is added at the beginning of the array if the index is negative,
2572    ///     or at the end of the array if it is positive.
2573    ///
2574    /// # Example
2575    ///
2576    /// ```rust
2577    /// # include!("../../doctest_setup.rs");
2578    /// #
2579    /// # fn main() {
2580    /// #     #[cfg(feature = "serde_json")]
2581    /// #     run_test().unwrap();
2582    /// # }
2583    /// #
2584    /// # #[cfg(feature = "serde_json")]
2585    /// # fn run_test() -> QueryResult<()> {
2586    /// #     use diesel::dsl::jsonb_set_create_if_missing;
2587    /// #     use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text};
2588    /// #     use serde_json::{json, Value};
2589    /// #     let connection = &mut establish_connection();
2590    ///
2591    /// let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Array<Text>, _, _, _, _>(
2592    ///         json!([{"f1":1,"f2":null},2,null,3]),
2593    ///         vec!["0","f1"],
2594    ///         json!([2,3,4]),
2595    ///         true
2596    ///     )).get_result::<Value>(connection)?;
2597    /// let expected: Value = json!([{"f1": [2, 3, 4], "f2": null}, 2, null, 3]);
2598    /// assert_eq!(result, expected);
2599    ///
2600    /// let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Array<Text>, _, _, _, _>(
2601    ///         json!([{"f1":1,"f2":null},2,null,3]),
2602    ///         vec!["0","f3"],
2603    ///         json!([2,3,4]),
2604    ///         false
2605    ///     )).get_result::<Value>(connection)?;
2606    /// let expected: Value = json!([{"f1":1, "f2": null},2, null, 3]);
2607    /// assert_eq!(result, expected);
2608    ///
2609    /// let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Array<Text>, _, _, _, _>(
2610    ///         json!([{"odd":[2,4,6,8]}]),
2611    ///         // not vec!["odd"], cannot set path in scalar
2612    ///         vec!["0","odd"],
2613    ///         json!([1,3,5,7]),
2614    ///         true
2615    ///     )).get_result::<Value>(connection)?;
2616    /// let expected: Value = json!([{"odd":[1,3,5,7]}]);
2617    /// assert_eq!(result, expected);
2618    ///
2619    /// let empty:Vec<String> = Vec::new();
2620    /// let result = diesel::select(jsonb_set_create_if_missing::<Nullable<Jsonb>, Array<Nullable<Text>>, _, _, _, _>(
2621    ///         None::<Value>,
2622    ///         empty,
2623    ///         None::<Value>,
2624    ///         true
2625    ///     )).get_result::<Option<Value>>(connection)?;
2626    /// assert!(result.is_none());
2627    ///
2628    /// let empty:Vec<String> = Vec::new();
2629    /// let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Array<Nullable<Text>>, _, _, _, _>(
2630    ///         // cannot be json!(null)
2631    ///         json!([]),
2632    ///         empty,
2633    ///         json!(null),
2634    ///         true
2635    ///     )).get_result::<Value>(connection)?;
2636    /// let expected = json!([]);
2637    /// assert_eq!(result, expected);
2638    ///
2639    /// let result = diesel::select(jsonb_set_create_if_missing::<Jsonb, Nullable<Array<Nullable<Text>>>, _, _, _, _>(
2640    ///         json!(null),
2641    ///         None::<Vec<String>>,
2642    ///         json!({"foo": 42}),
2643    ///         true
2644    ///     )).get_result::<Option<Value>>(connection)?;
2645    /// assert!(result.is_none());
2646    ///
2647    ///
2648    /// #     Ok(())
2649    /// # }
2650    /// ```
2651    #[sql_name = "jsonb_set"]
2652    fn jsonb_set_create_if_missing<
2653        E: JsonbOrNullableJsonb + SingleValue,
2654        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2655    >(
2656        base: E,
2657        path: Arr,
2658        new_value: E,
2659        create_if_missing: Bool,
2660    ) -> Arr::Out;
2661
2662    /// Returns target with the item designated by path replaced by new_value,
2663    ///     or with new_value added and the item designated by path does not exist.
2664    ///
2665    /// It can't set path in scalar
2666    ///
2667    /// All earlier steps in the path must exist, or the target is returned unchanged.
2668    /// As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays.
2669    /// If the last path step is an array index that is out of range,
2670    ///    the new value is added at the beginning of the array if the index is negative,
2671    ///     or at the end of the array if it is positive.
2672    ///
2673    /// If new_value is not NULL, behaves identically to jsonb_set.
2674    ///    Otherwise behaves according to the value of null_value_treatment
2675    ///    which must be one of 'raise_exception', 'use_json_null', 'delete_key', or 'return_target'.
2676    ///    The default is 'use_json_null'.
2677    ///
2678    /// # Example
2679    ///
2680    /// ```rust
2681    /// # include!("../../doctest_setup.rs");
2682    /// #
2683    /// # fn main() {
2684    /// #     #[cfg(feature = "serde_json")]
2685    /// #     run_test().unwrap();
2686    /// # }
2687    /// #
2688    /// # #[cfg(feature = "serde_json")]
2689    /// # fn run_test() -> QueryResult<()> {
2690    /// #     use diesel::dsl::jsonb_set_lax;
2691    /// #     use diesel::sql_types::{Jsonb,Array,NullValueTreatment, Json, Nullable, Text};
2692    /// #     use serde_json::{json,Value};
2693    /// #     let connection = &mut establish_connection();
2694    ///
2695    /// let null_value_treatment = NullValueTreatment::UseJsonNull;
2696    /// let result = diesel::select(jsonb_set_lax::<Jsonb, Array<Text>, _, _, _, _, _>(
2697    ///         json!([{"f1":1,"f2":null},2,null,3]),
2698    ///         vec!["0","f1"],
2699    ///         json!([2,3,4]),
2700    ///         true,
2701    ///         null_value_treatment
2702    ///     )).get_result::<Value>(connection)?;
2703    /// let expected: Value = json!([{"f1": [2, 3, 4], "f2": null}, 2, null, 3]);
2704    /// assert_eq!(result, expected);
2705    ///
2706    /// let null_value_treatment = NullValueTreatment::ReturnTarget;
2707    /// let result = diesel::select(jsonb_set_lax::<Nullable<Jsonb>, Array<Nullable<Text>>, _, _, _, _, _>(
2708    ///         json!([{"f1":99,"f2":null},2]),
2709    ///         vec!["0","f3"],
2710    ///         None::<Value>,
2711    ///         true,
2712    ///         null_value_treatment
2713    ///     )).get_result::<Option<Value>>(connection)?;
2714    /// assert_eq!(result, Some(json!([{"f1":99,"f2":null},2])));
2715    ///
2716    /// let null_value_treatment = NullValueTreatment::UseJsonNull;
2717    /// let empty:Vec<String> = Vec::new();
2718    /// let result = diesel::select(jsonb_set_lax::<Jsonb, Array<Nullable<Text>>, _, _, _, _, _>(
2719    ///         // cannot be json!(null)
2720    ///         json!([]),
2721    ///         empty,
2722    ///         json!(null),
2723    ///         true,
2724    ///         null_value_treatment
2725    ///     )).get_result::<Value>(connection)?;
2726    /// let expected = json!([]);
2727    /// assert_eq!(result, expected);
2728    ///
2729    /// let null_value_treatment = NullValueTreatment::UseJsonNull;
2730    /// let result = diesel::select(jsonb_set_lax::<Jsonb, Nullable<Array<Nullable<Text>>>, _, _, _, _, _,>(
2731    ///         json!(null),
2732    ///         None::<Vec<String>>,
2733    ///         json!({"foo": 42}),
2734    ///         true,
2735    ///         null_value_treatment
2736    ///     )).get_result::<Option<Value>>(connection)?;
2737    /// assert!(result.is_none());
2738    ///
2739    /// #     Ok(())
2740    /// # }
2741    /// ```
2742    fn jsonb_set_lax<
2743        E: JsonbOrNullableJsonb + SingleValue,
2744        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2745    >(
2746        base: E,
2747        path: Arr,
2748        new_value: E,
2749        create_if_missing: Bool,
2750        null_value_treatment: NullValueTreatmentEnum,
2751    ) -> Arr::Out;
2752
2753    /// Returns target with `new_value` inserted into `base`.
2754    ///
2755    /// If the item designated by the `path` is an array element, `new_value` will be inserted before that item
2756    ///
2757    /// If the item designated by the `path` is an object field, `new_value` will be
2758    /// inserted only if the object does not already contain that key.
2759    ///
2760    /// * All earlier steps in the path must exist, or the target is returned unchanged.
2761    /// * As with the path oriented operators, negative integers that appear in the `path` count
2762    ///   from the end of JSON arrays.
2763    /// * If the last `path` step is an array index that is out of range,
2764    ///   the new value is added at the beginning of the array if the index is negative,
2765    ///   or at the end of the array if it is positive.
2766    ///
2767    /// # Example
2768    ///
2769    /// ```rust
2770    /// # include!("../../doctest_setup.rs");
2771    /// #
2772    /// # fn main() {
2773    /// #     #[cfg(feature = "serde_json")]
2774    /// #     run_test().unwrap();
2775    /// # }
2776    /// #
2777    /// # #[cfg(feature = "serde_json")]
2778    /// # fn run_test() -> QueryResult<()> {
2779    /// #     use diesel::dsl::jsonb_insert;
2780    /// #     use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text};
2781    /// #     use serde_json::{json,Value};
2782    /// #     let connection = &mut establish_connection();
2783    ///
2784    /// let result = diesel::select(jsonb_insert::<Jsonb, Array<Text>, _, _, _>(
2785    ///         json!({"a":[0,1,2]}),
2786    ///         vec!["a","1"],
2787    ///         json!("new_value"),
2788    ///     )).get_result::<Value>(connection)?;
2789    /// let expected: Value = json!({"a":[0,"new_value",1,2]});
2790    /// assert_eq!(result, expected);
2791    ///
2792    /// let result = diesel::select(jsonb_insert::<Nullable<Jsonb>, Array<Text>, _, _, _>(
2793    ///         None::<serde_json::Value>,
2794    ///         vec!["a","1"],
2795    ///         Some(json!("new_value")),
2796    ///     )).get_result::<Option<Value>>(connection)?;
2797    /// assert_eq!(result, None);
2798    ///
2799    /// #     Ok(())
2800    /// # }
2801    /// ```
2802    fn jsonb_insert<
2803        E: JsonbOrNullableJsonb + SingleValue,
2804        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2805    >(
2806        base: E,
2807        path: Arr,
2808        new_value: E,
2809    ) -> Arr::Out;
2810
2811    /// Returns target with `new_value` inserted into `base`.
2812    ///
2813    /// If the item designated by the `path` is an array element, `new_value` will be inserted before that
2814    /// item if `insert_after` is false (which is the default),
2815    /// or after it if `insert_after` is true.
2816    ///
2817    /// If the item designated by the `path` is an object field, `new_value` will be inserted only
2818    /// if the object does not already contain that key.
2819    ///
2820    /// * All earlier steps in the `path` must exist, or the target is returned unchanged.
2821    /// * As with the path oriented operators, negative integers that appear in the `path` count
2822    ///   from the end of JSON arrays.
2823    /// * If the last `path` step is an array index that is out of range,
2824    ///   the new value is added at the beginning of the array if the index is negative,
2825    ///   or at the end of the array if it is positive.
2826    ///
2827    /// # Example
2828    ///
2829    /// ```rust
2830    /// # include!("../../doctest_setup.rs");
2831    /// #
2832    /// # fn main() {
2833    /// #     #[cfg(feature = "serde_json")]
2834    /// #     run_test().unwrap();
2835    /// # }
2836    /// #
2837    /// # #[cfg(feature = "serde_json")]
2838    /// # fn run_test() -> QueryResult<()> {
2839    /// #     use diesel::dsl::jsonb_insert_with_insert_after;
2840    /// #     use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text};
2841    /// #     use serde_json::{json,Value};
2842    /// #     let connection = &mut establish_connection();
2843    ///
2844    /// let result = diesel::select(jsonb_insert_with_insert_after::<Jsonb, Array<Text>, _, _, _, _>(
2845    ///         json!({"a":[0,1,2]}),
2846    ///         vec!["a","1"],
2847    ///         json!("new_value"),
2848    ///         false
2849    ///     )).get_result::<Value>(connection)?;
2850    /// let expected: Value = json!({"a":[0,"new_value",1,2]});
2851    /// assert_eq!(result, expected);
2852    ///
2853    /// let result = diesel::select(jsonb_insert_with_insert_after::<Jsonb, Array<Text>, _, _, _, _>(
2854    ///         json!({"a":[0,1,2]}),
2855    ///         vec!["a","1"],
2856    ///         json!("new_value"),
2857    ///         true
2858    ///     )).get_result::<Value>(connection)?;
2859    /// let expected: Value = json!({"a":[0,1,"new_value",2,]});
2860    /// assert_eq!(result, expected);
2861    ///
2862    /// #     Ok(())
2863    /// # }
2864    /// ```
2865    #[sql_name = "jsonb_insert"]
2866    fn jsonb_insert_with_insert_after<
2867        E: JsonbOrNullableJsonb + SingleValue,
2868        Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2869    >(
2870        base: E,
2871        path: Arr,
2872        new_value: E,
2873        insert_after: Bool,
2874    ) -> Arr::Out;
2875}