1use 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::pg::expression::expression_methods::TextOrNullableText;
16use crate::sql_types::helper::CombinedNullableValue;
17use crate::sql_types::*;
18
19#[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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __abbrev_return_type {
#[doc = "Return type of the [`abbrev()`](fn@super::abbrev) SQL function."]
pub type abbrev<addr> =
super::abbrev<<addr as diesel::expression::Expression>::SqlType,
addr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __broadcast_return_type {
#[doc =
"Return type of the [`broadcast()`](fn@super::broadcast) SQL function."]
pub type broadcast<addr> =
super::broadcast<<addr as diesel::expression::Expression>::SqlType,
addr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __family_return_type {
#[doc = "Return type of the [`family()`](fn@super::family) SQL function."]
pub type family<addr> =
super::family<<addr as diesel::expression::Expression>::SqlType,
addr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __host_return_type {
#[doc = "Return type of the [`host()`](fn@super::host) SQL function."]
pub type host<addr> =
super::host<<addr as diesel::expression::Expression>::SqlType, addr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __hostmask_return_type {
#[doc =
"Return type of the [`hostmask()`](fn@super::hostmask) SQL function."]
pub type hostmask<addr> =
super::hostmask<<addr as diesel::expression::Expression>::SqlType,
addr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
U: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __inet_merge_return_type {
#[doc =
"Return type of the [`inet_merge()`](fn@super::inet_merge) SQL function."]
pub type inet_merge<a, b> =
super::inet_merge<<a as diesel::expression::Expression>::SqlType,
<b as diesel::expression::Expression>::SqlType, a, b>;
}
#[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: ::core::marker::PhantomData<T>,
pub(in super) U: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
U: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __inet_same_family_return_type {
#[doc =
"Return type of the [`inet_same_family()`](fn@super::inet_same_family) SQL function."]
pub type inet_same_family<a, b> =
super::inet_same_family<<a as
diesel::expression::Expression>::SqlType,
<b as diesel::expression::Expression>::SqlType, a, b>;
}
#[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: ::core::marker::PhantomData<T>,
pub(in super) U: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __masklen_return_type {
#[doc =
"Return type of the [`masklen()`](fn@super::masklen) SQL function."]
pub type masklen<addr> =
super::masklen<<addr as diesel::expression::Expression>::SqlType,
addr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __netmask_return_type {
#[doc =
"Return type of the [`netmask()`](fn@super::netmask) SQL function."]
pub type netmask<addr> =
super::netmask<<addr as diesel::expression::Expression>::SqlType,
addr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __network_return_type {
#[doc =
"Return type of the [`network()`](fn@super::network) SQL function."]
pub type network<addr> =
super::network<<addr as diesel::expression::Expression>::SqlType,
addr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __set_masklen_return_type {
#[doc =
"Return type of the [`set_masklen()`](fn@super::set_masklen) SQL function."]
pub type set_masklen<addr, len> =
super::set_masklen<<addr as diesel::expression::Expression>::SqlType,
addr, len>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __lower_return_type {
#[doc = "Return type of the [`lower()`](fn@super::lower) SQL function."]
pub type lower<range> =
super::lower<<range as diesel::expression::Expression>::SqlType,
range>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __upper_return_type {
#[doc = "Return type of the [`upper()`](fn@super::upper) SQL function."]
pub type upper<range> =
super::upper<<range as diesel::expression::Expression>::SqlType,
range>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __isempty_return_type {
#[doc =
"Return type of the [`isempty()`](fn@super::isempty) SQL function."]
pub type isempty<range> =
super::isempty<<range as diesel::expression::Expression>::SqlType,
range>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __lower_inc_return_type {
#[doc =
"Return type of the [`lower_inc()`](fn@super::lower_inc) SQL function."]
pub type lower_inc<range> =
super::lower_inc<<range as diesel::expression::Expression>::SqlType,
range>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __upper_inc_return_type {
#[doc =
"Return type of the [`upper_inc()`](fn@super::upper_inc) SQL function."]
pub type upper_inc<range> =
super::upper_inc<<range as diesel::expression::Expression>::SqlType,
range>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __lower_inf_return_type {
#[doc =
"Return type of the [`lower_inf()`](fn@super::lower_inf) SQL function."]
pub type lower_inf<range> =
super::lower_inf<<range as diesel::expression::Expression>::SqlType,
range>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __upper_inf_return_type {
#[doc =
"Return type of the [`upper_inf()`](fn@super::upper_inf) SQL function."]
pub type upper_inf<range> =
super::upper_inf<<range as diesel::expression::Expression>::SqlType,
range>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
R2: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __range_merge_return_type {
#[doc =
"Return type of the [`range_merge()`](fn@super::range_merge) SQL function."]
pub type range_merge<lhs, rhs> =
super::range_merge<<lhs as diesel::expression::Expression>::SqlType,
<rhs as diesel::expression::Expression>::SqlType, lhs, rhs>;
}
#[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: ::core::marker::PhantomData<R1>,
pub(in super) R2: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __multirange_merge_return_type {
#[doc =
"Return type of the [`multirange_merge()`](fn@super::multirange_merge) SQL function."]
pub type multirange_merge<multirange> =
super::multirange_merge<<multirange as
diesel::expression::Expression>::SqlType, multirange>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __int4range_return_type {
#[doc =
"Return type of the [`int4range()`](fn@super::int4range) SQL function."]
pub type int4range<lower, upper, bound> =
super::int4range<lower, upper, bound>;
}
#[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> ::core::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> ::core::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> ::core::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> ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __int8range_return_type {
#[doc =
"Return type of the [`int8range()`](fn@super::int8range) SQL function."]
pub type int8range<lower, upper, bound> =
super::int8range<lower, upper, bound>;
}
#[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> ::core::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> ::core::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> ::core::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> ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __numrange_return_type {
#[doc =
"Return type of the [`numrange()`](fn@super::numrange) SQL function."]
pub type numrange<lower, upper, bound> =
super::numrange<lower, upper, bound>;
}
#[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> ::core::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> ::core::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> ::core::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> ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __tsrange_return_type {
#[doc =
"Return type of the [`tsrange()`](fn@super::tsrange) SQL function."]
pub type tsrange<lower, upper, bound> =
super::tsrange<lower, upper, bound>;
}
#[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> ::core::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> ::core::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> ::core::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> ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __tstzrange_return_type {
#[doc =
"Return type of the [`tstzrange()`](fn@super::tstzrange) SQL function."]
pub type tstzrange<lower, upper, bound> =
super::tstzrange<lower, upper, bound>;
}
#[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> ::core::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> ::core::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> ::core::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> ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __daterange_return_type {
#[doc =
"Return type of the [`daterange()`](fn@super::daterange) SQL function."]
pub type daterange<lower, upper, bound> =
super::daterange<lower, upper, bound>;
}
#[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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
T: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_append_return_type {
#[doc =
"Return type of the [`array_append()`](fn@super::array_append) SQL function."]
pub type array_append<a, e> =
super::array_append<<a as diesel::expression::Expression>::SqlType,
<e as diesel::expression::Expression>::SqlType, a, e>;
}
#[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: ::core::marker::PhantomData<Arr>,
pub(in super) T: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
T: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_replace_return_type {
#[doc =
"Return type of the [`array_replace()`](fn@super::array_replace) SQL function."]
pub type array_replace<a, e, r> =
super::array_replace<<a as diesel::expression::Expression>::SqlType,
<e as diesel::expression::Expression>::SqlType, a, e, r>;
}
#[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: ::core::marker::PhantomData<Arr>,
pub(in super) T: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_dims_return_type {
#[doc =
"Return type of the [`array_dims()`](fn@super::array_dims) SQL function."]
pub type array_dims<arr> =
super::array_dims<<arr as diesel::expression::Expression>::SqlType,
arr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
Arr: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_prepend_return_type {
#[doc =
"Return type of the [`array_prepend()`](fn@super::array_prepend) SQL function."]
pub type array_prepend<e, a> =
super::array_prepend<<e as diesel::expression::Expression>::SqlType,
<a as diesel::expression::Expression>::SqlType, e, a>;
}
#[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: ::core::marker::PhantomData<T>,
pub(in super) Arr: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
T: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_remove_return_type {
#[doc =
"Return type of the [`array_remove()`](fn@super::array_remove) SQL function."]
pub type array_remove<a, e> =
super::array_remove<<a as diesel::expression::Expression>::SqlType,
<e as diesel::expression::Expression>::SqlType, a, e>;
}
#[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: ::core::marker::PhantomData<Arr>,
pub(in super) T: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_to_string_with_null_string_return_type {
#[doc =
"Return type of the [`array_to_string_with_null_string()`](fn@super::array_to_string_with_null_string) SQL function."]
pub type array_to_string_with_null_string<array, del, null> =
super::array_to_string_with_null_string<<array as
diesel::expression::Expression>::SqlType, array, del, null>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_to_string_return_type {
#[doc =
"Return type of the [`array_to_string()`](fn@super::array_to_string) SQL function."]
pub type array_to_string<array, del> =
super::array_to_string<<array as
diesel::expression::Expression>::SqlType, array, del>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __cardinality_return_type {
#[doc =
"Return type of the [`cardinality()`](fn@super::cardinality) SQL function."]
pub type cardinality<a> =
super::cardinality<<a as diesel::expression::Expression>::SqlType, a>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __trim_array_return_type {
#[doc =
"Return type of the [`trim_array()`](fn@super::trim_array) SQL function."]
pub type trim_array<a, n> =
super::trim_array<<a as diesel::expression::Expression>::SqlType, a,
n>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_cat_return_type {
#[doc =
"Return type of the [`array_cat()`](fn@super::array_cat) SQL function."]
pub type array_cat<a, b> =
super::array_cat<<a as diesel::expression::Expression>::SqlType, a,
b>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_length_return_type {
#[doc =
"Return type of the [`array_length()`](fn@super::array_length) SQL function."]
pub type array_length<array, dimension> =
super::array_length<<array as
diesel::expression::Expression>::SqlType, array, dimension>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_fill_return_type {
#[doc =
"Return type of the [`array_fill()`](fn@super::array_fill) SQL function."]
pub type array_fill<value, dim> =
super::array_fill<<value as diesel::expression::Expression>::SqlType,
value, dim>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_fill_with_lower_bound_return_type {
#[doc =
"Return type of the [`array_fill_with_lower_bound()`](fn@super::array_fill_with_lower_bound) SQL function."]
pub type array_fill_with_lower_bound<value, dim, lower_bound> =
super::array_fill_with_lower_bound<<value as
diesel::expression::Expression>::SqlType, value, dim, lower_bound>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_lower_return_type {
#[doc =
"Return type of the [`array_lower()`](fn@super::array_lower) SQL function."]
pub type array_lower<array, dimension> =
super::array_lower<<array as diesel::expression::Expression>::SqlType,
array, dimension>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
E: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_position_return_type {
#[doc =
"Return type of the [`array_position()`](fn@super::array_position) SQL function."]
pub type array_position<a, elem> =
super::array_position<<a as diesel::expression::Expression>::SqlType,
<elem as diesel::expression::Expression>::SqlType, a, elem>;
}
#[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: ::core::marker::PhantomData<Arr>,
pub(in super) E: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
E: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_position_with_subscript_return_type {
#[doc =
"Return type of the [`array_position_with_subscript()`](fn@super::array_position_with_subscript) SQL function."]
pub type array_position_with_subscript<a, elem, subscript> =
super::array_position_with_subscript<<a as
diesel::expression::Expression>::SqlType,
<elem as diesel::expression::Expression>::SqlType, a, elem,
subscript>;
}
#[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: ::core::marker::PhantomData<Arr>,
pub(in super) E: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
E: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_positions_return_type {
#[doc =
"Return type of the [`array_positions()`](fn@super::array_positions) SQL function."]
pub type array_positions<a, elem> =
super::array_positions<<a as diesel::expression::Expression>::SqlType,
<elem as diesel::expression::Expression>::SqlType, a, elem>;
}
#[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: ::core::marker::PhantomData<Arr>,
pub(in super) E: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_ndims_return_type {
#[doc =
"Return type of the [`array_ndims()`](fn@super::array_ndims) SQL function."]
pub type array_ndims<arr> =
super::array_ndims<<arr as diesel::expression::Expression>::SqlType,
arr>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_upper_return_type {
#[doc =
"Return type of the [`array_upper()`](fn@super::array_upper) SQL function."]
pub type array_upper<array, dimension> =
super::array_upper<<array as diesel::expression::Expression>::SqlType,
array, dimension>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_shuffle_return_type {
#[doc =
"Return type of the [`array_shuffle()`](fn@super::array_shuffle) SQL function."]
pub type array_shuffle<array> =
super::array_shuffle<<array as
diesel::expression::Expression>::SqlType, array>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_sample_return_type {
#[doc =
"Return type of the [`array_sample()`](fn@super::array_sample) SQL function."]
pub type array_sample<array, n> =
super::array_sample<<array as
diesel::expression::Expression>::SqlType, array, n>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __array_to_json_return_type {
#[doc =
"Return type of the [`array_to_json()`](fn@super::array_to_json) SQL function."]
pub type array_to_json<array> =
super::array_to_json<<array as
diesel::expression::Expression>::SqlType, array>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __to_json_return_type {
#[doc =
"Return type of the [`to_json()`](fn@super::to_json) SQL function."]
pub type to_json<e> =
super::to_json<<e as diesel::expression::Expression>::SqlType, e>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __to_jsonb_return_type {
#[doc =
"Return type of the [`to_jsonb()`](fn@super::to_jsonb) SQL function."]
pub type to_jsonb<e> =
super::to_jsonb<<e as diesel::expression::Expression>::SqlType, e>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_object_return_type {
#[doc =
"Return type of the [`json_object()`](fn@super::json_object) SQL function."]
pub type json_object<text_array> =
super::json_object<<text_array as
diesel::expression::Expression>::SqlType, text_array>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
Arr2: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_object_with_keys_and_values_return_type {
#[doc =
"Return type of the [`json_object_with_keys_and_values()`](fn@super::json_object_with_keys_and_values) SQL function."]
pub type json_object_with_keys_and_values<keys, values> =
super::json_object_with_keys_and_values<<keys as
diesel::expression::Expression>::SqlType,
<values as diesel::expression::Expression>::SqlType, keys, values>;
}
#[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: ::core::marker::PhantomData<Arr1>,
pub(in super) Arr2: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_typeof_return_type {
#[doc =
"Return type of the [`json_typeof()`](fn@super::json_typeof) SQL function."]
pub type json_typeof<e> =
super::json_typeof<<e as diesel::expression::Expression>::SqlType, e>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_typeof_return_type {
#[doc =
"Return type of the [`jsonb_typeof()`](fn@super::jsonb_typeof) SQL function."]
pub type jsonb_typeof<e> =
super::jsonb_typeof<<e as diesel::expression::Expression>::SqlType,
e>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_pretty_return_type {
#[doc =
"Return type of the [`jsonb_pretty()`](fn@super::jsonb_pretty) SQL function."]
pub type jsonb_pretty<e> =
super::jsonb_pretty<<e as diesel::expression::Expression>::SqlType,
e>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_strip_nulls_return_type {
#[doc =
"Return type of the [`json_strip_nulls()`](fn@super::json_strip_nulls) SQL function."]
pub type json_strip_nulls<json> =
super::json_strip_nulls<<json as
diesel::expression::Expression>::SqlType, json>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_strip_nulls_return_type {
#[doc =
"Return type of the [`jsonb_strip_nulls()`](fn@super::jsonb_strip_nulls) SQL function."]
pub type jsonb_strip_nulls<jsonb> =
super::jsonb_strip_nulls<<jsonb as
diesel::expression::Expression>::SqlType, jsonb>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_array_length_return_type {
#[doc =
"Return type of the [`json_array_length()`](fn@super::json_array_length) SQL function."]
pub type json_array_length<json> =
super::json_array_length<<json as
diesel::expression::Expression>::SqlType, json>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_array_length_return_type {
#[doc =
"Return type of the [`jsonb_array_length()`](fn@super::jsonb_array_length) SQL function."]
pub type jsonb_array_length<jsonb> =
super::jsonb_array_length<<jsonb as
diesel::expression::Expression>::SqlType, jsonb>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_object_return_type {
#[doc =
"Return type of the [`jsonb_object()`](fn@super::jsonb_object) SQL function."]
pub type jsonb_object<text_array> =
super::jsonb_object<<text_array as
diesel::expression::Expression>::SqlType, text_array>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
Arr2: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_object_with_keys_and_values_return_type {
#[doc =
"Return type of the [`jsonb_object_with_keys_and_values()`](fn@super::jsonb_object_with_keys_and_values) SQL function."]
pub type jsonb_object_with_keys_and_values<keys, values> =
super::jsonb_object_with_keys_and_values<<keys as
diesel::expression::Expression>::SqlType,
<values as diesel::expression::Expression>::SqlType, keys, values>;
}
#[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: ::core::marker::PhantomData<Arr1>,
pub(in super) Arr2: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __row_to_json_return_type {
#[doc =
"Return type of the [`row_to_json()`](fn@super::row_to_json) SQL function."]
pub type row_to_json<record> =
super::row_to_json<<record as
diesel::expression::Expression>::SqlType, record>;
}
#[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: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
J: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_populate_record_return_type {
#[doc =
"Return type of the [`json_populate_record()`](fn@super::json_populate_record) SQL function."]
pub type json_populate_record<base, from_json> =
super::json_populate_record<<base as
diesel::expression::Expression>::SqlType,
<from_json as diesel::expression::Expression>::SqlType, base,
from_json>;
}
#[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: ::core::marker::PhantomData<B>,
pub(in super) J: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
J: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_populate_record_return_type {
#[doc =
"Return type of the [`jsonb_populate_record()`](fn@super::jsonb_populate_record) SQL function."]
pub type jsonb_populate_record<base, from_json> =
super::jsonb_populate_record<<base as
diesel::expression::Expression>::SqlType,
<from_json as diesel::expression::Expression>::SqlType, base,
from_json>;
}
#[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: ::core::marker::PhantomData<B>,
pub(in super) J: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
Arr: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_set_return_type {
#[doc =
"Return type of the [`jsonb_set()`](fn@super::jsonb_set) SQL function."]
pub type jsonb_set<base, path, new_value> =
super::jsonb_set<<base as diesel::expression::Expression>::SqlType,
<path as diesel::expression::Expression>::SqlType, base, path,
new_value>;
}
#[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: ::core::marker::PhantomData<E>,
pub(in super) Arr: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
Arr: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_set_create_if_missing_return_type {
#[doc =
"Return type of the [`jsonb_set_create_if_missing()`](fn@super::jsonb_set_create_if_missing) SQL function."]
pub type
jsonb_set_create_if_missing<base, path, new_value, create_if_missing>
=
super::jsonb_set_create_if_missing<<base as
diesel::expression::Expression>::SqlType,
<path as diesel::expression::Expression>::SqlType, base, path,
new_value, create_if_missing>;
}
#[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: ::core::marker::PhantomData<E>,
pub(in super) Arr: ::core::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>
::core::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>
::core::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>
::core::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>
::core::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: ::core::marker::PhantomData,
Arr: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_set_lax_return_type {
#[doc =
"Return type of the [`jsonb_set_lax()`](fn@super::jsonb_set_lax) SQL function."]
pub type
jsonb_set_lax<base, path, new_value, create_if_missing,
null_value_treatment> =
super::jsonb_set_lax<<base as
diesel::expression::Expression>::SqlType,
<path as diesel::expression::Expression>::SqlType, base, path,
new_value, create_if_missing, null_value_treatment>;
}
#[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: ::core::marker::PhantomData<E>,
pub(in super) Arr: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
Arr: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_insert_return_type {
#[doc =
"Return type of the [`jsonb_insert()`](fn@super::jsonb_insert) SQL function."]
pub type jsonb_insert<base, path, new_value> =
super::jsonb_insert<<base as diesel::expression::Expression>::SqlType,
<path as diesel::expression::Expression>::SqlType, base, path,
new_value>;
}
#[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: ::core::marker::PhantomData<E>,
pub(in super) Arr: ::core::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> ::core::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> ::core::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> ::core::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> ::core::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: ::core::marker::PhantomData,
Arr: ::core::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>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_insert_with_insert_after_return_type {
#[doc =
"Return type of the [`jsonb_insert_with_insert_after()`](fn@super::jsonb_insert_with_insert_after) SQL function."]
pub type
jsonb_insert_with_insert_after<base, path, new_value, insert_after> =
super::jsonb_insert_with_insert_after<<base as
diesel::expression::Expression>::SqlType,
<path as diesel::expression::Expression>::SqlType, base, path,
new_value, insert_after>;
}
#[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: ::core::marker::PhantomData<E>,
pub(in super) Arr: ::core::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>
::core::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>
::core::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>
::core::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>
::core::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;
}
}
#[doc =
" Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list. Each argument is converted as per to_json."]
#[doc = ""]
#[doc = ""]
#[doc = " # Example"]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`json_build_array_0`, `json_build_array_1`, ... `json_build_array_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "json_build_array")]
#[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_build_array_1, json_build_array_2, json_build_array_0};"]
#[doc =
" # use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text, Integer, Record, Double};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Record<(Text, Double)>, _>(sql::<Record<(Text, Double)>>(\"ROW(\'abc\',3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":\"abc\","]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Array<Integer>, _>(vec![1, 2, 3]))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([ [1, 2, 3] ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_2::<Nullable<Text>, Double, _, _>(None::<String>, 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([None::<String>, 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Record<(Nullable<Text>, Double)>, _>(sql::<Record<(Nullable<Text>, Double)>>(\"ROW(null,3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":None::<String>,"]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_build_array_0() -> json_build_array_0 where {
json_build_array_0_utils::json_build_array_0 {}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_build_array_0()`](fn@json_build_array_0)"]
pub type json_build_array_0 = json_build_array_0_utils::json_build_array_0<>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_build_array_0_return_type {
#[doc =
"Return type of the [`json_build_array_0()`](fn@super::json_build_array_0) SQL function."]
pub type json_build_array_0 = super::json_build_array_0<>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_build_array_0_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_build_array_0 {}
#[automatically_derived]
impl ::core::fmt::Debug for json_build_array_0 {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "json_build_array_0")
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for json_build_array_0 { }
#[automatically_derived]
impl ::core::clone::Clone for json_build_array_0 {
#[inline]
fn clone(&self) -> json_build_array_0 { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for json_build_array_0 { }
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for json_build_array_0 {
type QueryId = json_build_array_0<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[doc =
"The return type of [`json_build_array_0()`](fn@json_build_array_0)"]
pub type HelperType = json_build_array_0<>;
impl Expression for json_build_array_0 where {
type SqlType = Json;
}
impl<__DieselInternal> SelectableExpression<__DieselInternal> for
json_build_array_0 where Self: AppearsOnTable<__DieselInternal> {}
impl<__DieselInternal> AppearsOnTable<__DieselInternal> for
json_build_array_0 where Self: Expression {}
impl<__DieselInternal> FunctionFragment<__DieselInternal> for
json_build_array_0 where __DieselInternal: diesel::backend::Backend {
const FUNCTION_NAME: &'static str = "json_build_array";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
Ok(())
}
}
impl QueryFragment<crate::pg::Pg> for json_build_array_0 where {
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();
const _: () =
{
use diesel;
impl<__GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived {
type IsAggregate = diesel::expression::is_aggregate::Never;
}
};
impl<__DieselInternal> ValidGrouping<__DieselInternal> for
json_build_array_0 where __Derived<>: ValidGrouping<__DieselInternal>
{
type IsAggregate =
<__Derived<> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list. Each argument is converted as per to_json."]
#[doc = ""]
#[doc = ""]
#[doc = " # Example"]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`json_build_array_0`, `json_build_array_1`, ... `json_build_array_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "json_build_array")]
#[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_build_array_1, json_build_array_2, json_build_array_0};"]
#[doc =
" # use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text, Integer, Record, Double};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Record<(Text, Double)>, _>(sql::<Record<(Text, Double)>>(\"ROW(\'abc\',3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":\"abc\","]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Array<Integer>, _>(vec![1, 2, 3]))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([ [1, 2, 3] ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_2::<Nullable<Text>, Double, _, _>(None::<String>, 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([None::<String>, 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Record<(Nullable<Text>, Double)>, _>(sql::<Record<(Nullable<Text>, Double)>>(\"ROW(null,3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":None::<String>,"]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_build_array_1<V1: SingleValue, value_1>(value_1: value_1)
-> json_build_array_1<V1, value_1> where
value_1: diesel::expression::AsExpression<V1> {
json_build_array_1_utils::json_build_array_1 {
value_1: value_1.as_expression(),
V1: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_build_array_1()`](fn@json_build_array_1)"]
pub type json_build_array_1<V1, value_1> =
json_build_array_1_utils::json_build_array_1<V1,
<value_1 as diesel::expression::AsExpression<V1>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_build_array_1_return_type {
#[doc =
"Return type of the [`json_build_array_1()`](fn@super::json_build_array_1) SQL function."]
pub type json_build_array_1<value_1> =
super::json_build_array_1<<value_1 as
diesel::expression::Expression>::SqlType, value_1>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_build_array_1_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_build_array_1<V1, value_1> {
pub(in super) value_1: value_1,
pub(in super) V1: ::core::marker::PhantomData<V1>,
}
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<V1, value_1, __Rhs> ::core::ops::Add<__Rhs> for
json_build_array_1<V1, value_1> 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<V1, value_1, __Rhs> ::core::ops::Sub<__Rhs> for
json_build_array_1<V1, value_1> 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<V1, value_1, __Rhs> ::core::ops::Mul<__Rhs> for
json_build_array_1<V1, value_1> 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<V1, value_1, __Rhs> ::core::ops::Div<__Rhs> for
json_build_array_1<V1, value_1> 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<V1: ::core::fmt::Debug, value_1: ::core::fmt::Debug>
::core::fmt::Debug for json_build_array_1<V1, value_1> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"json_build_array_1", "value_1", &self.value_1, "V1",
&&self.V1)
}
}
#[automatically_derived]
impl<V1: ::core::clone::Clone, value_1: ::core::clone::Clone>
::core::clone::Clone for json_build_array_1<V1, value_1> {
#[inline]
fn clone(&self) -> json_build_array_1<V1, value_1> {
json_build_array_1 {
value_1: ::core::clone::Clone::clone(&self.value_1),
V1: ::core::clone::Clone::clone(&self.V1),
}
}
}
#[automatically_derived]
impl<V1: ::core::marker::Copy, value_1: ::core::marker::Copy>
::core::marker::Copy for json_build_array_1<V1, value_1> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<V1: diesel::query_builder::QueryId,
value_1: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_build_array_1<V1, value_1> {
type QueryId =
json_build_array_1<<V1 as
diesel::query_builder::QueryId>::QueryId,
<value_1 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<V1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<value_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<V1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<value_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_build_array_1()`](fn@json_build_array_1)"]
pub type HelperType<V1, value_1> =
json_build_array_1<V1, <value_1 as AsExpression<V1>>::Expression>;
impl<V1: SingleValue, value_1> Expression for
json_build_array_1<V1, value_1> where (value_1): Expression {
type SqlType = Json;
}
impl<V1: SingleValue, value_1, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_build_array_1<V1, value_1> where
value_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<V1: SingleValue, value_1, __DieselInternal>
AppearsOnTable<__DieselInternal> for json_build_array_1<V1, value_1>
where value_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<V1: SingleValue, value_1, __DieselInternal>
FunctionFragment<__DieselInternal> for json_build_array_1<V1, value_1>
where __DieselInternal: diesel::backend::Backend,
value_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_build_array";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.value_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.value_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<V1: SingleValue, value_1> QueryFragment<crate::pg::Pg> for
json_build_array_1<V1, value_1> where
value_1: 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_1>(value_1);
const _: () =
{
use diesel;
impl<value_1, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<value_1> where
value_1: diesel::expression::ValidGrouping<__GroupByClause> {
type IsAggregate =
<value_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
}
};
impl<V1: SingleValue, value_1, __DieselInternal>
ValidGrouping<__DieselInternal> for json_build_array_1<V1, value_1>
where __Derived<value_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<value_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list. Each argument is converted as per to_json."]
#[doc = ""]
#[doc = ""]
#[doc = " # Example"]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`json_build_array_0`, `json_build_array_1`, ... `json_build_array_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "json_build_array")]
#[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_build_array_1, json_build_array_2, json_build_array_0};"]
#[doc =
" # use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text, Integer, Record, Double};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Record<(Text, Double)>, _>(sql::<Record<(Text, Double)>>(\"ROW(\'abc\',3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":\"abc\","]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Array<Integer>, _>(vec![1, 2, 3]))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([ [1, 2, 3] ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_2::<Nullable<Text>, Double, _, _>(None::<String>, 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([None::<String>, 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_build_array_1::<Record<(Nullable<Text>, Double)>, _>(sql::<Record<(Nullable<Text>, Double)>>(\"ROW(null,3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":None::<String>,"]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_build_array_2<V1: SingleValue, V2: SingleValue, value_1,
value_2>(value_1: value_1, value_2: value_2)
-> json_build_array_2<V1, V2, value_1, value_2> where
value_1: diesel::expression::AsExpression<V1>,
value_2: diesel::expression::AsExpression<V2> {
json_build_array_2_utils::json_build_array_2 {
value_1: value_1.as_expression(),
value_2: value_2.as_expression(),
V1: ::core::marker::PhantomData,
V2: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_build_array_2()`](fn@json_build_array_2)"]
pub type json_build_array_2<V1, V2, value_1, value_2> =
json_build_array_2_utils::json_build_array_2<V1, V2,
<value_1 as diesel::expression::AsExpression<V1>>::Expression,
<value_2 as diesel::expression::AsExpression<V2>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_build_array_2_return_type {
#[doc =
"Return type of the [`json_build_array_2()`](fn@super::json_build_array_2) SQL function."]
pub type json_build_array_2<value_1, value_2> =
super::json_build_array_2<<value_1 as
diesel::expression::Expression>::SqlType,
<value_2 as diesel::expression::Expression>::SqlType, value_1,
value_2>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_build_array_2_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_build_array_2<V1, V2, value_1, value_2> {
pub(in super) value_1: value_1,
pub(in super) value_2: value_2,
pub(in super) V1: ::core::marker::PhantomData<V1>,
pub(in super) V2: ::core::marker::PhantomData<V2>,
}
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<V1, V2, value_1, value_2, __Rhs> ::core::ops::Add<__Rhs> for
json_build_array_2<V1, V2, value_1, value_2> 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<V1, V2, value_1, value_2, __Rhs> ::core::ops::Sub<__Rhs> for
json_build_array_2<V1, V2, value_1, value_2> 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<V1, V2, value_1, value_2, __Rhs> ::core::ops::Mul<__Rhs> for
json_build_array_2<V1, V2, value_1, value_2> 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<V1, V2, value_1, value_2, __Rhs> ::core::ops::Div<__Rhs> for
json_build_array_2<V1, V2, value_1, value_2> 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<V1: ::core::fmt::Debug, V2: ::core::fmt::Debug,
value_1: ::core::fmt::Debug, value_2: ::core::fmt::Debug>
::core::fmt::Debug for json_build_array_2<V1, V2, value_1, value_2> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"json_build_array_2", "value_1", &self.value_1, "value_2",
&self.value_2, "V1", &self.V1, "V2", &&self.V2)
}
}
#[automatically_derived]
impl<V1: ::core::clone::Clone, V2: ::core::clone::Clone,
value_1: ::core::clone::Clone, value_2: ::core::clone::Clone>
::core::clone::Clone for json_build_array_2<V1, V2, value_1, value_2>
{
#[inline]
fn clone(&self) -> json_build_array_2<V1, V2, value_1, value_2> {
json_build_array_2 {
value_1: ::core::clone::Clone::clone(&self.value_1),
value_2: ::core::clone::Clone::clone(&self.value_2),
V1: ::core::clone::Clone::clone(&self.V1),
V2: ::core::clone::Clone::clone(&self.V2),
}
}
}
#[automatically_derived]
impl<V1: ::core::marker::Copy, V2: ::core::marker::Copy,
value_1: ::core::marker::Copy, value_2: ::core::marker::Copy>
::core::marker::Copy for json_build_array_2<V1, V2, value_1, value_2>
{
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<V1: diesel::query_builder::QueryId,
V2: diesel::query_builder::QueryId,
value_1: diesel::query_builder::QueryId,
value_2: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_build_array_2<V1, V2, value_1, value_2> {
type QueryId =
json_build_array_2<<V1 as
diesel::query_builder::QueryId>::QueryId,
<V2 as diesel::query_builder::QueryId>::QueryId,
<value_1 as diesel::query_builder::QueryId>::QueryId,
<value_2 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<V1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<V2 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<value_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<value_2 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<V1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<V2 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<value_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<value_2 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_build_array_2()`](fn@json_build_array_2)"]
pub type HelperType<V1, V2, value_1, value_2> =
json_build_array_2<V1, V2, <value_1 as AsExpression<V1>>::Expression,
<value_2 as AsExpression<V2>>::Expression>;
impl<V1: SingleValue, V2: SingleValue, value_1, value_2> Expression for
json_build_array_2<V1, V2, value_1, value_2> where
(value_1, value_2): Expression {
type SqlType = Json;
}
impl<V1: SingleValue, V2: SingleValue, value_1, value_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_build_array_2<V1, V2, value_1, value_2> where
value_1: SelectableExpression<__DieselInternal>,
value_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<V1: SingleValue, V2: SingleValue, value_1, value_2, __DieselInternal>
AppearsOnTable<__DieselInternal> for
json_build_array_2<V1, V2, value_1, value_2> where
value_1: AppearsOnTable<__DieselInternal>,
value_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<V1: SingleValue, V2: SingleValue, value_1, value_2, __DieselInternal>
FunctionFragment<__DieselInternal> for
json_build_array_2<V1, V2, value_1, value_2> where
__DieselInternal: diesel::backend::Backend,
value_1: QueryFragment<__DieselInternal>,
value_2: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_build_array";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.value_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.value_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.value_2.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.value_2.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<V1: SingleValue, V2: SingleValue, value_1, value_2>
QueryFragment<crate::pg::Pg> for
json_build_array_2<V1, V2, value_1, value_2> where
value_1: QueryFragment<crate::pg::Pg>,
value_2: 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_1, value_2>(value_1, value_2);
const _: () =
{
use diesel;
impl<value_1, value_2, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<value_1, value_2> where
value_1: diesel::expression::ValidGrouping<__GroupByClause>,
value_2: diesel::expression::ValidGrouping<__GroupByClause>,
<value_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<value_2
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<value_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<value_2 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<V1: SingleValue, V2: SingleValue, value_1, value_2, __DieselInternal>
ValidGrouping<__DieselInternal> for
json_build_array_2<V1, V2, value_1, value_2> where
__Derived<value_1, value_2>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<value_1, value_2> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[allow(unused_imports)]
#[doc(inline)]
mod __json_build_array_return_types {
#[doc(inline)]
pub use super::__json_build_array_0_return_type::*;
#[doc(inline)]
pub use super::__json_build_array_1_return_type::*;
#[doc(inline)]
pub use super::__json_build_array_2_return_type::*;
}
#[doc =
" Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list. Each argument is converted as per to_jsonb."]
#[doc = ""]
#[doc = ""]
#[doc = " # Example"]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`jsonb_build_array_0`, `jsonb_build_array_1`, ... `jsonb_build_array_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "jsonb_build_array")]
#[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_build_array_1, jsonb_build_array_2, jsonb_build_array_0};"]
#[doc =
" # use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text, Integer, Record, Double};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Record<(Text, Double)>, _>(sql::<Record<(Text, Double)>>(\"ROW(\'abc\',3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":\"abc\","]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Array<Integer>, _>(vec![1, 2, 3]))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([ [1, 2, 3] ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_2::<Nullable<Text>, Double, _, _>(None::<String>, 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([None::<String>, 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Record<(Nullable<Text>, Double)>, _>(sql::<Record<(Nullable<Text>, Double)>>(\"ROW(null,3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":None::<String>,"]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_build_array_0() -> jsonb_build_array_0 where {
jsonb_build_array_0_utils::jsonb_build_array_0 {}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_build_array_0()`](fn@jsonb_build_array_0)"]
pub type jsonb_build_array_0 =
jsonb_build_array_0_utils::jsonb_build_array_0<>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_build_array_0_return_type {
#[doc =
"Return type of the [`jsonb_build_array_0()`](fn@super::jsonb_build_array_0) SQL function."]
pub type jsonb_build_array_0 = super::jsonb_build_array_0<>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_build_array_0_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_build_array_0 {}
#[automatically_derived]
impl ::core::fmt::Debug for jsonb_build_array_0 {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "jsonb_build_array_0")
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for jsonb_build_array_0 { }
#[automatically_derived]
impl ::core::clone::Clone for jsonb_build_array_0 {
#[inline]
fn clone(&self) -> jsonb_build_array_0 { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for jsonb_build_array_0 { }
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for jsonb_build_array_0 {
type QueryId = jsonb_build_array_0<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[doc =
"The return type of [`jsonb_build_array_0()`](fn@jsonb_build_array_0)"]
pub type HelperType = jsonb_build_array_0<>;
impl Expression for jsonb_build_array_0 where {
type SqlType = Jsonb;
}
impl<__DieselInternal> SelectableExpression<__DieselInternal> for
jsonb_build_array_0 where Self: AppearsOnTable<__DieselInternal> {}
impl<__DieselInternal> AppearsOnTable<__DieselInternal> for
jsonb_build_array_0 where Self: Expression {}
impl<__DieselInternal> FunctionFragment<__DieselInternal> for
jsonb_build_array_0 where __DieselInternal: diesel::backend::Backend {
const FUNCTION_NAME: &'static str = "jsonb_build_array";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
Ok(())
}
}
impl QueryFragment<crate::pg::Pg> for jsonb_build_array_0 where {
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();
const _: () =
{
use diesel;
impl<__GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived {
type IsAggregate = diesel::expression::is_aggregate::Never;
}
};
impl<__DieselInternal> ValidGrouping<__DieselInternal> for
jsonb_build_array_0 where __Derived<>: ValidGrouping<__DieselInternal>
{
type IsAggregate =
<__Derived<> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list. Each argument is converted as per to_jsonb."]
#[doc = ""]
#[doc = ""]
#[doc = " # Example"]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`jsonb_build_array_0`, `jsonb_build_array_1`, ... `jsonb_build_array_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "jsonb_build_array")]
#[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_build_array_1, jsonb_build_array_2, jsonb_build_array_0};"]
#[doc =
" # use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text, Integer, Record, Double};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Record<(Text, Double)>, _>(sql::<Record<(Text, Double)>>(\"ROW(\'abc\',3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":\"abc\","]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Array<Integer>, _>(vec![1, 2, 3]))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([ [1, 2, 3] ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_2::<Nullable<Text>, Double, _, _>(None::<String>, 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([None::<String>, 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Record<(Nullable<Text>, Double)>, _>(sql::<Record<(Nullable<Text>, Double)>>(\"ROW(null,3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":None::<String>,"]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_build_array_1<V1: SingleValue, value_1>(value_1: value_1)
-> jsonb_build_array_1<V1, value_1> where
value_1: diesel::expression::AsExpression<V1> {
jsonb_build_array_1_utils::jsonb_build_array_1 {
value_1: value_1.as_expression(),
V1: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_build_array_1()`](fn@jsonb_build_array_1)"]
pub type jsonb_build_array_1<V1, value_1> =
jsonb_build_array_1_utils::jsonb_build_array_1<V1,
<value_1 as diesel::expression::AsExpression<V1>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_build_array_1_return_type {
#[doc =
"Return type of the [`jsonb_build_array_1()`](fn@super::jsonb_build_array_1) SQL function."]
pub type jsonb_build_array_1<value_1> =
super::jsonb_build_array_1<<value_1 as
diesel::expression::Expression>::SqlType, value_1>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_build_array_1_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_build_array_1<V1, value_1> {
pub(in super) value_1: value_1,
pub(in super) V1: ::core::marker::PhantomData<V1>,
}
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<V1, value_1, __Rhs> ::core::ops::Add<__Rhs> for
jsonb_build_array_1<V1, value_1> 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<V1, value_1, __Rhs> ::core::ops::Sub<__Rhs> for
jsonb_build_array_1<V1, value_1> 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<V1, value_1, __Rhs> ::core::ops::Mul<__Rhs> for
jsonb_build_array_1<V1, value_1> 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<V1, value_1, __Rhs> ::core::ops::Div<__Rhs> for
jsonb_build_array_1<V1, value_1> 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<V1: ::core::fmt::Debug, value_1: ::core::fmt::Debug>
::core::fmt::Debug for jsonb_build_array_1<V1, value_1> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"jsonb_build_array_1", "value_1", &self.value_1, "V1",
&&self.V1)
}
}
#[automatically_derived]
impl<V1: ::core::clone::Clone, value_1: ::core::clone::Clone>
::core::clone::Clone for jsonb_build_array_1<V1, value_1> {
#[inline]
fn clone(&self) -> jsonb_build_array_1<V1, value_1> {
jsonb_build_array_1 {
value_1: ::core::clone::Clone::clone(&self.value_1),
V1: ::core::clone::Clone::clone(&self.V1),
}
}
}
#[automatically_derived]
impl<V1: ::core::marker::Copy, value_1: ::core::marker::Copy>
::core::marker::Copy for jsonb_build_array_1<V1, value_1> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<V1: diesel::query_builder::QueryId,
value_1: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_build_array_1<V1, value_1> {
type QueryId =
jsonb_build_array_1<<V1 as
diesel::query_builder::QueryId>::QueryId,
<value_1 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<V1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<value_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<V1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<value_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`jsonb_build_array_1()`](fn@jsonb_build_array_1)"]
pub type HelperType<V1, value_1> =
jsonb_build_array_1<V1, <value_1 as AsExpression<V1>>::Expression>;
impl<V1: SingleValue, value_1> Expression for
jsonb_build_array_1<V1, value_1> where (value_1): Expression {
type SqlType = Jsonb;
}
impl<V1: SingleValue, value_1, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_build_array_1<V1, value_1> where
value_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<V1: SingleValue, value_1, __DieselInternal>
AppearsOnTable<__DieselInternal> for jsonb_build_array_1<V1, value_1>
where value_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<V1: SingleValue, value_1, __DieselInternal>
FunctionFragment<__DieselInternal> for
jsonb_build_array_1<V1, value_1> where
__DieselInternal: diesel::backend::Backend,
value_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_build_array";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.value_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.value_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<V1: SingleValue, value_1> QueryFragment<crate::pg::Pg> for
jsonb_build_array_1<V1, value_1> where
value_1: 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_1>(value_1);
const _: () =
{
use diesel;
impl<value_1, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<value_1> where
value_1: diesel::expression::ValidGrouping<__GroupByClause> {
type IsAggregate =
<value_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
}
};
impl<V1: SingleValue, value_1, __DieselInternal>
ValidGrouping<__DieselInternal> for jsonb_build_array_1<V1, value_1>
where __Derived<value_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<value_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list. Each argument is converted as per to_jsonb."]
#[doc = ""]
#[doc = ""]
#[doc = " # Example"]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`jsonb_build_array_0`, `jsonb_build_array_1`, ... `jsonb_build_array_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "jsonb_build_array")]
#[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_build_array_1, jsonb_build_array_2, jsonb_build_array_0};"]
#[doc =
" # use diesel::sql_types::{Jsonb, Array, Json, Nullable, Text, Integer, Record, Double};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Record<(Text, Double)>, _>(sql::<Record<(Text, Double)>>(\"ROW(\'abc\',3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":\"abc\","]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Array<Integer>, _>(vec![1, 2, 3]))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([ [1, 2, 3] ]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_2::<Nullable<Text>, Double, _, _>(None::<String>, 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([None::<String>, 3.1415]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_build_array_1::<Record<(Nullable<Text>, Double)>, _>(sql::<Record<(Nullable<Text>, Double)>>(\"ROW(null,3.1415)\")))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!(["]
#[doc = " {"]
#[doc = " \"f1\":None::<String>,"]
#[doc = " \"f2\":3.1415"]
#[doc = " }"]
#[doc = " ]), result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_build_array_2<V1: SingleValue, V2: SingleValue, value_1,
value_2>(value_1: value_1, value_2: value_2)
-> jsonb_build_array_2<V1, V2, value_1, value_2> where
value_1: diesel::expression::AsExpression<V1>,
value_2: diesel::expression::AsExpression<V2> {
jsonb_build_array_2_utils::jsonb_build_array_2 {
value_1: value_1.as_expression(),
value_2: value_2.as_expression(),
V1: ::core::marker::PhantomData,
V2: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_build_array_2()`](fn@jsonb_build_array_2)"]
pub type jsonb_build_array_2<V1, V2, value_1, value_2> =
jsonb_build_array_2_utils::jsonb_build_array_2<V1, V2,
<value_1 as diesel::expression::AsExpression<V1>>::Expression,
<value_2 as diesel::expression::AsExpression<V2>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_build_array_2_return_type {
#[doc =
"Return type of the [`jsonb_build_array_2()`](fn@super::jsonb_build_array_2) SQL function."]
pub type jsonb_build_array_2<value_1, value_2> =
super::jsonb_build_array_2<<value_1 as
diesel::expression::Expression>::SqlType,
<value_2 as diesel::expression::Expression>::SqlType, value_1,
value_2>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_build_array_2_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_build_array_2<V1, V2, value_1, value_2> {
pub(in super) value_1: value_1,
pub(in super) value_2: value_2,
pub(in super) V1: ::core::marker::PhantomData<V1>,
pub(in super) V2: ::core::marker::PhantomData<V2>,
}
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<V1, V2, value_1, value_2, __Rhs> ::core::ops::Add<__Rhs> for
jsonb_build_array_2<V1, V2, value_1, value_2> 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<V1, V2, value_1, value_2, __Rhs> ::core::ops::Sub<__Rhs> for
jsonb_build_array_2<V1, V2, value_1, value_2> 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<V1, V2, value_1, value_2, __Rhs> ::core::ops::Mul<__Rhs> for
jsonb_build_array_2<V1, V2, value_1, value_2> 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<V1, V2, value_1, value_2, __Rhs> ::core::ops::Div<__Rhs> for
jsonb_build_array_2<V1, V2, value_1, value_2> 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<V1: ::core::fmt::Debug, V2: ::core::fmt::Debug,
value_1: ::core::fmt::Debug, value_2: ::core::fmt::Debug>
::core::fmt::Debug for jsonb_build_array_2<V1, V2, value_1, value_2> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"jsonb_build_array_2", "value_1", &self.value_1, "value_2",
&self.value_2, "V1", &self.V1, "V2", &&self.V2)
}
}
#[automatically_derived]
impl<V1: ::core::clone::Clone, V2: ::core::clone::Clone,
value_1: ::core::clone::Clone, value_2: ::core::clone::Clone>
::core::clone::Clone for jsonb_build_array_2<V1, V2, value_1, value_2>
{
#[inline]
fn clone(&self) -> jsonb_build_array_2<V1, V2, value_1, value_2> {
jsonb_build_array_2 {
value_1: ::core::clone::Clone::clone(&self.value_1),
value_2: ::core::clone::Clone::clone(&self.value_2),
V1: ::core::clone::Clone::clone(&self.V1),
V2: ::core::clone::Clone::clone(&self.V2),
}
}
}
#[automatically_derived]
impl<V1: ::core::marker::Copy, V2: ::core::marker::Copy,
value_1: ::core::marker::Copy, value_2: ::core::marker::Copy>
::core::marker::Copy for jsonb_build_array_2<V1, V2, value_1, value_2>
{
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<V1: diesel::query_builder::QueryId,
V2: diesel::query_builder::QueryId,
value_1: diesel::query_builder::QueryId,
value_2: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_build_array_2<V1, V2, value_1, value_2> {
type QueryId =
jsonb_build_array_2<<V1 as
diesel::query_builder::QueryId>::QueryId,
<V2 as diesel::query_builder::QueryId>::QueryId,
<value_1 as diesel::query_builder::QueryId>::QueryId,
<value_2 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<V1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<V2 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<value_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<value_2 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<V1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<V2 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<value_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<value_2 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`jsonb_build_array_2()`](fn@jsonb_build_array_2)"]
pub type HelperType<V1, V2, value_1, value_2> =
jsonb_build_array_2<V1, V2, <value_1 as AsExpression<V1>>::Expression,
<value_2 as AsExpression<V2>>::Expression>;
impl<V1: SingleValue, V2: SingleValue, value_1, value_2> Expression for
jsonb_build_array_2<V1, V2, value_1, value_2> where
(value_1, value_2): Expression {
type SqlType = Jsonb;
}
impl<V1: SingleValue, V2: SingleValue, value_1, value_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_build_array_2<V1, V2, value_1, value_2> where
value_1: SelectableExpression<__DieselInternal>,
value_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<V1: SingleValue, V2: SingleValue, value_1, value_2, __DieselInternal>
AppearsOnTable<__DieselInternal> for
jsonb_build_array_2<V1, V2, value_1, value_2> where
value_1: AppearsOnTable<__DieselInternal>,
value_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<V1: SingleValue, V2: SingleValue, value_1, value_2, __DieselInternal>
FunctionFragment<__DieselInternal> for
jsonb_build_array_2<V1, V2, value_1, value_2> where
__DieselInternal: diesel::backend::Backend,
value_1: QueryFragment<__DieselInternal>,
value_2: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_build_array";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.value_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.value_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.value_2.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.value_2.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<V1: SingleValue, V2: SingleValue, value_1, value_2>
QueryFragment<crate::pg::Pg> for
jsonb_build_array_2<V1, V2, value_1, value_2> where
value_1: QueryFragment<crate::pg::Pg>,
value_2: 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_1, value_2>(value_1, value_2);
const _: () =
{
use diesel;
impl<value_1, value_2, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<value_1, value_2> where
value_1: diesel::expression::ValidGrouping<__GroupByClause>,
value_2: diesel::expression::ValidGrouping<__GroupByClause>,
<value_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<value_2
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<value_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<value_2 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<V1: SingleValue, V2: SingleValue, value_1, value_2, __DieselInternal>
ValidGrouping<__DieselInternal> for
jsonb_build_array_2<V1, V2, value_1, value_2> where
__Derived<value_1, value_2>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<value_1, value_2> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[allow(unused_imports)]
#[doc(inline)]
mod __jsonb_build_array_return_types {
#[doc(inline)]
pub use super::__jsonb_build_array_0_return_type::*;
#[doc(inline)]
pub use super::__jsonb_build_array_1_return_type::*;
#[doc(inline)]
pub use super::__jsonb_build_array_2_return_type::*;
}
#[doc =
" Extracts JSON sub-object at the specified path. (This is functionally equivalent to the #> operator, but writing the path out as a variadic list can be more convenient in some cases.)"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`json_extract_path_0`, `json_extract_path_1`, ... `json_extract_path_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "json_extract_path")]
#[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_extract_path_1, json_extract_path_2};"]
#[doc = " # use diesel::sql_types::{Json, Nullable, Text};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let expected = Some(json!({\"f5\":99, \"f6\":\"foo\"}));"]
#[doc =
" let result = diesel::select(json_extract_path_1::<Json, Text, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " ))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc = " let expected = Some(json!(\"foo\"));"]
#[doc =
" let result = diesel::select(json_extract_path_2::<Json, Text, Text, _, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " \"f6\""]
#[doc = " ))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_extract_path_1::<Nullable<Json>, Text, _, _>(None::<serde_json::Value>, \"f4\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<serde_json::Value>, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_extract_path_2::<Json, Nullable<Text>, Text, _, _, _>(json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}), None::<String>, \"f6\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = ""]
#[doc = " assert_eq!(None::<serde_json::Value>, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_extract_path_1<J: JsonOrNullableJson + SingleValue,
T1: SingleValue, json, text_1>(json: json, text_1: text_1)
-> json_extract_path_1<J, T1, json, text_1> where
json: diesel::expression::AsExpression<J>,
text_1: diesel::expression::AsExpression<T1> {
json_extract_path_1_utils::json_extract_path_1 {
json: json.as_expression(),
text_1: text_1.as_expression(),
J: ::core::marker::PhantomData,
T1: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_extract_path_1()`](fn@json_extract_path_1)"]
pub type json_extract_path_1<J, T1, json, text_1> =
json_extract_path_1_utils::json_extract_path_1<J, T1,
<json as diesel::expression::AsExpression<J>>::Expression,
<text_1 as diesel::expression::AsExpression<T1>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_extract_path_1_return_type {
#[doc =
"Return type of the [`json_extract_path_1()`](fn@super::json_extract_path_1) SQL function."]
pub type json_extract_path_1<json, text_1> =
super::json_extract_path_1<<json as
diesel::expression::Expression>::SqlType,
<text_1 as diesel::expression::Expression>::SqlType, json, text_1>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_extract_path_1_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_extract_path_1<J, T1, json, text_1> {
pub(in super) json: json,
pub(in super) text_1: text_1,
pub(in super) J: ::core::marker::PhantomData<J>,
pub(in super) T1: ::core::marker::PhantomData<T1>,
}
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<J, T1, json, text_1, __Rhs> ::core::ops::Add<__Rhs> for
json_extract_path_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Sub<__Rhs> for
json_extract_path_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Mul<__Rhs> for
json_extract_path_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Div<__Rhs> for
json_extract_path_1<J, T1, json, text_1> 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<J: ::core::fmt::Debug, T1: ::core::fmt::Debug,
json: ::core::fmt::Debug, text_1: ::core::fmt::Debug>
::core::fmt::Debug for json_extract_path_1<J, T1, json, text_1> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"json_extract_path_1", "json", &self.json, "text_1",
&self.text_1, "J", &self.J, "T1", &&self.T1)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, T1: ::core::clone::Clone,
json: ::core::clone::Clone, text_1: ::core::clone::Clone>
::core::clone::Clone for json_extract_path_1<J, T1, json, text_1> {
#[inline]
fn clone(&self) -> json_extract_path_1<J, T1, json, text_1> {
json_extract_path_1 {
json: ::core::clone::Clone::clone(&self.json),
text_1: ::core::clone::Clone::clone(&self.text_1),
J: ::core::clone::Clone::clone(&self.J),
T1: ::core::clone::Clone::clone(&self.T1),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, T1: ::core::marker::Copy,
json: ::core::marker::Copy, text_1: ::core::marker::Copy>
::core::marker::Copy for json_extract_path_1<J, T1, json, text_1> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
T1: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
text_1: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_extract_path_1<J, T1, json, text_1> {
type QueryId =
json_extract_path_1<<J as
diesel::query_builder::QueryId>::QueryId,
<T1 as diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<text_1 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<T1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<text_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_extract_path_1()`](fn@json_extract_path_1)"]
pub type HelperType<J, T1, json, text_1> =
json_extract_path_1<J, T1, <json as AsExpression<J>>::Expression,
<text_1 as AsExpression<T1>>::Expression>;
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue, json, text_1>
Expression for json_extract_path_1<J, T1, json, text_1> where
(json, text_1): Expression {
type SqlType = Nullable<Json>;
}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue, json, text_1,
__DieselInternal> SelectableExpression<__DieselInternal> for
json_extract_path_1<J, T1, json, text_1> where
json: SelectableExpression<__DieselInternal>,
text_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue, json, text_1,
__DieselInternal> AppearsOnTable<__DieselInternal> for
json_extract_path_1<J, T1, json, text_1> where
json: AppearsOnTable<__DieselInternal>,
text_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue, json, text_1,
__DieselInternal> FunctionFragment<__DieselInternal> for
json_extract_path_1<J, T1, json, text_1> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
text_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_extract_path";
#[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;
}
if !self.text_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue, json, text_1>
QueryFragment<crate::pg::Pg> for
json_extract_path_1<J, T1, json, text_1> where
json: QueryFragment<crate::pg::Pg>,
text_1: 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, text_1>(json, text_1);
const _: () =
{
use diesel;
impl<json, text_1, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, text_1> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
text_1: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<text_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue, json, text_1,
__DieselInternal> ValidGrouping<__DieselInternal> for
json_extract_path_1<J, T1, json, text_1> where
__Derived<json, text_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, text_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Extracts JSON sub-object at the specified path. (This is functionally equivalent to the #> operator, but writing the path out as a variadic list can be more convenient in some cases.)"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`json_extract_path_0`, `json_extract_path_1`, ... `json_extract_path_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "json_extract_path")]
#[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_extract_path_1, json_extract_path_2};"]
#[doc = " # use diesel::sql_types::{Json, Nullable, Text};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let expected = Some(json!({\"f5\":99, \"f6\":\"foo\"}));"]
#[doc =
" let result = diesel::select(json_extract_path_1::<Json, Text, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " ))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc = " let expected = Some(json!(\"foo\"));"]
#[doc =
" let result = diesel::select(json_extract_path_2::<Json, Text, Text, _, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " \"f6\""]
#[doc = " ))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_extract_path_1::<Nullable<Json>, Text, _, _>(None::<serde_json::Value>, \"f4\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<serde_json::Value>, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_extract_path_2::<Json, Nullable<Text>, Text, _, _, _>(json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}), None::<String>, \"f6\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = ""]
#[doc = " assert_eq!(None::<serde_json::Value>, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_extract_path_2<J: JsonOrNullableJson + SingleValue,
T1: SingleValue, T2: SingleValue, json, text_1,
text_2>(json: json, text_1: text_1, text_2: text_2)
-> json_extract_path_2<J, T1, T2, json, text_1, text_2> where
json: diesel::expression::AsExpression<J>,
text_1: diesel::expression::AsExpression<T1>,
text_2: diesel::expression::AsExpression<T2> {
json_extract_path_2_utils::json_extract_path_2 {
json: json.as_expression(),
text_1: text_1.as_expression(),
text_2: text_2.as_expression(),
J: ::core::marker::PhantomData,
T1: ::core::marker::PhantomData,
T2: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_extract_path_2()`](fn@json_extract_path_2)"]
pub type json_extract_path_2<J, T1, T2, json, text_1, text_2> =
json_extract_path_2_utils::json_extract_path_2<J, T1, T2,
<json as diesel::expression::AsExpression<J>>::Expression,
<text_1 as diesel::expression::AsExpression<T1>>::Expression,
<text_2 as diesel::expression::AsExpression<T2>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_extract_path_2_return_type {
#[doc =
"Return type of the [`json_extract_path_2()`](fn@super::json_extract_path_2) SQL function."]
pub type json_extract_path_2<json, text_1, text_2> =
super::json_extract_path_2<<json as
diesel::expression::Expression>::SqlType,
<text_1 as diesel::expression::Expression>::SqlType,
<text_2 as diesel::expression::Expression>::SqlType, json, text_1,
text_2>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_extract_path_2_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_extract_path_2<J, T1, T2, json, text_1, text_2> {
pub(in super) json: json,
pub(in super) text_1: text_1,
pub(in super) text_2: text_2,
pub(in super) J: ::core::marker::PhantomData<J>,
pub(in super) T1: ::core::marker::PhantomData<T1>,
pub(in super) T2: ::core::marker::PhantomData<T2>,
}
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Add<__Rhs> for
json_extract_path_2<J, T1, T2, json, text_1, text_2> 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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Sub<__Rhs> for
json_extract_path_2<J, T1, T2, json, text_1, text_2> 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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Mul<__Rhs> for
json_extract_path_2<J, T1, T2, json, text_1, text_2> 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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Div<__Rhs> for
json_extract_path_2<J, T1, T2, json, text_1, text_2> 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<J: ::core::fmt::Debug, T1: ::core::fmt::Debug,
T2: ::core::fmt::Debug, json: ::core::fmt::Debug,
text_1: ::core::fmt::Debug, text_2: ::core::fmt::Debug>
::core::fmt::Debug for
json_extract_path_2<J, T1, T2, json, text_1, text_2> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["json", "text_1", "text_2", "J", "T1", "T2"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.json, &self.text_1, &self.text_2, &self.J, &self.T1,
&&self.T2];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"json_extract_path_2", names, values)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, T1: ::core::clone::Clone,
T2: ::core::clone::Clone, json: ::core::clone::Clone,
text_1: ::core::clone::Clone, text_2: ::core::clone::Clone>
::core::clone::Clone for
json_extract_path_2<J, T1, T2, json, text_1, text_2> {
#[inline]
fn clone(&self)
-> json_extract_path_2<J, T1, T2, json, text_1, text_2> {
json_extract_path_2 {
json: ::core::clone::Clone::clone(&self.json),
text_1: ::core::clone::Clone::clone(&self.text_1),
text_2: ::core::clone::Clone::clone(&self.text_2),
J: ::core::clone::Clone::clone(&self.J),
T1: ::core::clone::Clone::clone(&self.T1),
T2: ::core::clone::Clone::clone(&self.T2),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, T1: ::core::marker::Copy,
T2: ::core::marker::Copy, json: ::core::marker::Copy,
text_1: ::core::marker::Copy, text_2: ::core::marker::Copy>
::core::marker::Copy for
json_extract_path_2<J, T1, T2, json, text_1, text_2> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
T1: diesel::query_builder::QueryId,
T2: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
text_1: diesel::query_builder::QueryId,
text_2: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_extract_path_2<J, T1, T2, json, text_1, text_2> {
type QueryId =
json_extract_path_2<<J as
diesel::query_builder::QueryId>::QueryId,
<T1 as diesel::query_builder::QueryId>::QueryId,
<T2 as diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<text_1 as diesel::query_builder::QueryId>::QueryId,
<text_2 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T2 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_2 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<T1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<T2 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<text_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<text_2 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_extract_path_2()`](fn@json_extract_path_2)"]
pub type HelperType<J, T1, T2, json, text_1, text_2> =
json_extract_path_2<J, T1, T2, <json as AsExpression<J>>::Expression,
<text_1 as AsExpression<T1>>::Expression,
<text_2 as AsExpression<T2>>::Expression>;
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2> Expression for
json_extract_path_2<J, T1, T2, json, text_1, text_2> where
(json, text_1, text_2): Expression {
type SqlType = Nullable<Json>;
}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_extract_path_2<J, T1, T2, json, text_1, text_2> where
json: SelectableExpression<__DieselInternal>,
text_1: SelectableExpression<__DieselInternal>,
text_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2, __DieselInternal>
AppearsOnTable<__DieselInternal> for
json_extract_path_2<J, T1, T2, json, text_1, text_2> where
json: AppearsOnTable<__DieselInternal>,
text_1: AppearsOnTable<__DieselInternal>,
text_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2, __DieselInternal>
FunctionFragment<__DieselInternal> for
json_extract_path_2<J, T1, T2, json, text_1, text_2> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
text_1: QueryFragment<__DieselInternal>,
text_2: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_extract_path";
#[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;
}
if !self.text_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.text_2.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_2.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2> QueryFragment<crate::pg::Pg>
for json_extract_path_2<J, T1, T2, json, text_1, text_2> where
json: QueryFragment<crate::pg::Pg>,
text_1: QueryFragment<crate::pg::Pg>,
text_2: 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, text_1, text_2>(json, text_1, text_2);
const _: () =
{
use diesel;
impl<json, text_1, text_2, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, text_1, text_2> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
text_1: diesel::expression::ValidGrouping<__GroupByClause>,
text_2: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<text_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<text_2
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
as
diesel::expression::MixedAggregates<<text_2 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2, __DieselInternal>
ValidGrouping<__DieselInternal> for
json_extract_path_2<J, T1, T2, json, text_1, text_2> where
__Derived<json, text_1, text_2>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, text_1, text_2> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[allow(unused_imports)]
#[doc(inline)]
mod __json_extract_path_return_types {
#[doc(inline)]
pub use super::__json_extract_path_1_return_type::*;
#[doc(inline)]
pub use super::__json_extract_path_2_return_type::*;
}
#[doc =
" Extracts JSON sub-object at the specified path. (This is functionally equivalent to the #> operator, but writing the path out as a variadic list can be more convenient in some cases.)"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`jsonb_extract_path_0`, `jsonb_extract_path_1`, ... `jsonb_extract_path_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "jsonb_extract_path")]
#[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_extract_path_1, jsonb_extract_path_2};"]
#[doc = " # use diesel::sql_types::{Jsonb, Nullable, Text};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let expected = Some(json!({\"f5\":99, \"f6\":\"foo\"}));"]
#[doc =
" let result = diesel::select(jsonb_extract_path_1::<Jsonb, Text, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " ))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc = " let expected = Some(json!(\"foo\"));"]
#[doc =
" let result = diesel::select(jsonb_extract_path_2::<Jsonb, Text, Text, _, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " \"f6\""]
#[doc = " ))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_extract_path_1::<Nullable<Jsonb>, Text, _, _>(None::<serde_json::Value>, \"f4\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<serde_json::Value>, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_extract_path_2::<Jsonb, Nullable<Text>, Text, _, _, _>(json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}), None::<String>, \"f6\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = ""]
#[doc = " assert_eq!(None::<serde_json::Value>, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_extract_path_1<J: JsonbOrNullableJsonb + SingleValue,
T1: SingleValue, json, text_1>(json: json, text_1: text_1)
-> jsonb_extract_path_1<J, T1, json, text_1> where
json: diesel::expression::AsExpression<J>,
text_1: diesel::expression::AsExpression<T1> {
jsonb_extract_path_1_utils::jsonb_extract_path_1 {
json: json.as_expression(),
text_1: text_1.as_expression(),
J: ::core::marker::PhantomData,
T1: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_extract_path_1()`](fn@jsonb_extract_path_1)"]
pub type jsonb_extract_path_1<J, T1, json, text_1> =
jsonb_extract_path_1_utils::jsonb_extract_path_1<J, T1,
<json as diesel::expression::AsExpression<J>>::Expression,
<text_1 as diesel::expression::AsExpression<T1>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_extract_path_1_return_type {
#[doc =
"Return type of the [`jsonb_extract_path_1()`](fn@super::jsonb_extract_path_1) SQL function."]
pub type jsonb_extract_path_1<json, text_1> =
super::jsonb_extract_path_1<<json as
diesel::expression::Expression>::SqlType,
<text_1 as diesel::expression::Expression>::SqlType, json, text_1>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_extract_path_1_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_extract_path_1<J, T1, json, text_1> {
pub(in super) json: json,
pub(in super) text_1: text_1,
pub(in super) J: ::core::marker::PhantomData<J>,
pub(in super) T1: ::core::marker::PhantomData<T1>,
}
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<J, T1, json, text_1, __Rhs> ::core::ops::Add<__Rhs> for
jsonb_extract_path_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Sub<__Rhs> for
jsonb_extract_path_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Mul<__Rhs> for
jsonb_extract_path_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Div<__Rhs> for
jsonb_extract_path_1<J, T1, json, text_1> 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<J: ::core::fmt::Debug, T1: ::core::fmt::Debug,
json: ::core::fmt::Debug, text_1: ::core::fmt::Debug>
::core::fmt::Debug for jsonb_extract_path_1<J, T1, json, text_1> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"jsonb_extract_path_1", "json", &self.json, "text_1",
&self.text_1, "J", &self.J, "T1", &&self.T1)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, T1: ::core::clone::Clone,
json: ::core::clone::Clone, text_1: ::core::clone::Clone>
::core::clone::Clone for jsonb_extract_path_1<J, T1, json, text_1> {
#[inline]
fn clone(&self) -> jsonb_extract_path_1<J, T1, json, text_1> {
jsonb_extract_path_1 {
json: ::core::clone::Clone::clone(&self.json),
text_1: ::core::clone::Clone::clone(&self.text_1),
J: ::core::clone::Clone::clone(&self.J),
T1: ::core::clone::Clone::clone(&self.T1),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, T1: ::core::marker::Copy,
json: ::core::marker::Copy, text_1: ::core::marker::Copy>
::core::marker::Copy for jsonb_extract_path_1<J, T1, json, text_1> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
T1: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
text_1: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_extract_path_1<J, T1, json, text_1> {
type QueryId =
jsonb_extract_path_1<<J as
diesel::query_builder::QueryId>::QueryId,
<T1 as diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<text_1 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<T1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<text_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`jsonb_extract_path_1()`](fn@jsonb_extract_path_1)"]
pub type HelperType<J, T1, json, text_1> =
jsonb_extract_path_1<J, T1, <json as AsExpression<J>>::Expression,
<text_1 as AsExpression<T1>>::Expression>;
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue, json, text_1>
Expression for jsonb_extract_path_1<J, T1, json, text_1> where
(json, text_1): Expression {
type SqlType = Nullable<Jsonb>;
}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue, json, text_1,
__DieselInternal> SelectableExpression<__DieselInternal> for
jsonb_extract_path_1<J, T1, json, text_1> where
json: SelectableExpression<__DieselInternal>,
text_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue, json, text_1,
__DieselInternal> AppearsOnTable<__DieselInternal> for
jsonb_extract_path_1<J, T1, json, text_1> where
json: AppearsOnTable<__DieselInternal>,
text_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue, json, text_1,
__DieselInternal> FunctionFragment<__DieselInternal> for
jsonb_extract_path_1<J, T1, json, text_1> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
text_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_extract_path";
#[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;
}
if !self.text_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue, json, text_1>
QueryFragment<crate::pg::Pg> for
jsonb_extract_path_1<J, T1, json, text_1> where
json: QueryFragment<crate::pg::Pg>,
text_1: 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, text_1>(json, text_1);
const _: () =
{
use diesel;
impl<json, text_1, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, text_1> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
text_1: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<text_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue, json, text_1,
__DieselInternal> ValidGrouping<__DieselInternal> for
jsonb_extract_path_1<J, T1, json, text_1> where
__Derived<json, text_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, text_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Extracts JSON sub-object at the specified path. (This is functionally equivalent to the #> operator, but writing the path out as a variadic list can be more convenient in some cases.)"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`jsonb_extract_path_0`, `jsonb_extract_path_1`, ... `jsonb_extract_path_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "jsonb_extract_path")]
#[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_extract_path_1, jsonb_extract_path_2};"]
#[doc = " # use diesel::sql_types::{Jsonb, Nullable, Text};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let expected = Some(json!({\"f5\":99, \"f6\":\"foo\"}));"]
#[doc =
" let result = diesel::select(jsonb_extract_path_1::<Jsonb, Text, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " ))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc = " let expected = Some(json!(\"foo\"));"]
#[doc =
" let result = diesel::select(jsonb_extract_path_2::<Jsonb, Text, Text, _, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " \"f6\""]
#[doc = " ))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_extract_path_1::<Nullable<Jsonb>, Text, _, _>(None::<serde_json::Value>, \"f4\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<serde_json::Value>, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_extract_path_2::<Jsonb, Nullable<Text>, Text, _, _, _>(json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}), None::<String>, \"f6\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = ""]
#[doc = ""]
#[doc = " assert_eq!(None::<serde_json::Value>, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_extract_path_2<J: JsonbOrNullableJsonb + SingleValue,
T1: SingleValue, T2: SingleValue, json, text_1,
text_2>(json: json, text_1: text_1, text_2: text_2)
-> jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> where
json: diesel::expression::AsExpression<J>,
text_1: diesel::expression::AsExpression<T1>,
text_2: diesel::expression::AsExpression<T2> {
jsonb_extract_path_2_utils::jsonb_extract_path_2 {
json: json.as_expression(),
text_1: text_1.as_expression(),
text_2: text_2.as_expression(),
J: ::core::marker::PhantomData,
T1: ::core::marker::PhantomData,
T2: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_extract_path_2()`](fn@jsonb_extract_path_2)"]
pub type jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> =
jsonb_extract_path_2_utils::jsonb_extract_path_2<J, T1, T2,
<json as diesel::expression::AsExpression<J>>::Expression,
<text_1 as diesel::expression::AsExpression<T1>>::Expression,
<text_2 as diesel::expression::AsExpression<T2>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_extract_path_2_return_type {
#[doc =
"Return type of the [`jsonb_extract_path_2()`](fn@super::jsonb_extract_path_2) SQL function."]
pub type jsonb_extract_path_2<json, text_1, text_2> =
super::jsonb_extract_path_2<<json as
diesel::expression::Expression>::SqlType,
<text_1 as diesel::expression::Expression>::SqlType,
<text_2 as diesel::expression::Expression>::SqlType, json, text_1,
text_2>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_extract_path_2_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_extract_path_2<J, T1, T2, json, text_1, text_2> {
pub(in super) json: json,
pub(in super) text_1: text_1,
pub(in super) text_2: text_2,
pub(in super) J: ::core::marker::PhantomData<J>,
pub(in super) T1: ::core::marker::PhantomData<T1>,
pub(in super) T2: ::core::marker::PhantomData<T2>,
}
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Add<__Rhs> for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> 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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Sub<__Rhs> for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> 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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Mul<__Rhs> for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> 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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Div<__Rhs> for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> 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<J: ::core::fmt::Debug, T1: ::core::fmt::Debug,
T2: ::core::fmt::Debug, json: ::core::fmt::Debug,
text_1: ::core::fmt::Debug, text_2: ::core::fmt::Debug>
::core::fmt::Debug for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["json", "text_1", "text_2", "J", "T1", "T2"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.json, &self.text_1, &self.text_2, &self.J, &self.T1,
&&self.T2];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"jsonb_extract_path_2", names, values)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, T1: ::core::clone::Clone,
T2: ::core::clone::Clone, json: ::core::clone::Clone,
text_1: ::core::clone::Clone, text_2: ::core::clone::Clone>
::core::clone::Clone for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> {
#[inline]
fn clone(&self)
-> jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> {
jsonb_extract_path_2 {
json: ::core::clone::Clone::clone(&self.json),
text_1: ::core::clone::Clone::clone(&self.text_1),
text_2: ::core::clone::Clone::clone(&self.text_2),
J: ::core::clone::Clone::clone(&self.J),
T1: ::core::clone::Clone::clone(&self.T1),
T2: ::core::clone::Clone::clone(&self.T2),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, T1: ::core::marker::Copy,
T2: ::core::marker::Copy, json: ::core::marker::Copy,
text_1: ::core::marker::Copy, text_2: ::core::marker::Copy>
::core::marker::Copy for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
T1: diesel::query_builder::QueryId,
T2: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
text_1: diesel::query_builder::QueryId,
text_2: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> {
type QueryId =
jsonb_extract_path_2<<J as
diesel::query_builder::QueryId>::QueryId,
<T1 as diesel::query_builder::QueryId>::QueryId,
<T2 as diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<text_1 as diesel::query_builder::QueryId>::QueryId,
<text_2 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T2 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_2 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<T1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<T2 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<text_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<text_2 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`jsonb_extract_path_2()`](fn@jsonb_extract_path_2)"]
pub type HelperType<J, T1, T2, json, text_1, text_2> =
jsonb_extract_path_2<J, T1, T2, <json as AsExpression<J>>::Expression,
<text_1 as AsExpression<T1>>::Expression,
<text_2 as AsExpression<T2>>::Expression>;
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2> Expression for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> where
(json, text_1, text_2): Expression {
type SqlType = Nullable<Jsonb>;
}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> where
json: SelectableExpression<__DieselInternal>,
text_1: SelectableExpression<__DieselInternal>,
text_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2, __DieselInternal>
AppearsOnTable<__DieselInternal> for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> where
json: AppearsOnTable<__DieselInternal>,
text_1: AppearsOnTable<__DieselInternal>,
text_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2, __DieselInternal>
FunctionFragment<__DieselInternal> for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
text_1: QueryFragment<__DieselInternal>,
text_2: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_extract_path";
#[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;
}
if !self.text_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.text_2.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_2.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2> QueryFragment<crate::pg::Pg>
for jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> where
json: QueryFragment<crate::pg::Pg>,
text_1: QueryFragment<crate::pg::Pg>,
text_2: 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, text_1, text_2>(json, text_1, text_2);
const _: () =
{
use diesel;
impl<json, text_1, text_2, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, text_1, text_2> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
text_1: diesel::expression::ValidGrouping<__GroupByClause>,
text_2: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<text_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<text_2
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
as
diesel::expression::MixedAggregates<<text_2 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue,
T2: SingleValue, json, text_1, text_2, __DieselInternal>
ValidGrouping<__DieselInternal> for
jsonb_extract_path_2<J, T1, T2, json, text_1, text_2> where
__Derived<json, text_1, text_2>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, text_1, text_2> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[allow(unused_imports)]
#[doc(inline)]
mod __jsonb_extract_path_return_types {
#[doc(inline)]
pub use super::__jsonb_extract_path_1_return_type::*;
#[doc(inline)]
pub use super::__jsonb_extract_path_2_return_type::*;
}
#[doc =
" Extracts JSON sub-object at the specified path as text. (This is functionally equivalent to the #>> operator.)"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`json_extract_path_text_0`, `json_extract_path_text_1`, ... `json_extract_path_text_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "json_extract_path_text")]
#[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_extract_path_text_1, json_extract_path_text_2};"]
#[doc = " # use diesel::sql_types::{Json, Nullable, Text};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let expected = Some(String::from(\"{\\\"f5\\\":99,\\\"f6\\\":\\\"foo\\\"}\"));"]
#[doc =
" let result = diesel::select(json_extract_path_text_1::<Json, Text, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " ))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc = " let expected = Some(String::from(\"foo\"));"]
#[doc =
" let result = diesel::select(json_extract_path_text_2::<Json, Text, Text, _, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " \"f6\""]
#[doc = " ))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_extract_path_text_1::<Nullable<Json>, Text, _, _>(None::<serde_json::Value>, \"f4\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<String>, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_extract_path_text_2::<Json, Nullable<Text>, Text, _, _, _>(json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}), None::<String>, \"f6\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<String>, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_extract_path_text_1<J: JsonOrNullableJson + SingleValue,
T1: SingleValue + TextOrNullableText, json,
text_1>(json: json, text_1: text_1)
-> json_extract_path_text_1<J, T1, json, text_1> where
json: diesel::expression::AsExpression<J>,
text_1: diesel::expression::AsExpression<T1> {
json_extract_path_text_1_utils::json_extract_path_text_1 {
json: json.as_expression(),
text_1: text_1.as_expression(),
J: ::core::marker::PhantomData,
T1: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_extract_path_text_1()`](fn@json_extract_path_text_1)"]
pub type json_extract_path_text_1<J, T1, json, text_1> =
json_extract_path_text_1_utils::json_extract_path_text_1<J, T1,
<json as diesel::expression::AsExpression<J>>::Expression,
<text_1 as diesel::expression::AsExpression<T1>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_extract_path_text_1_return_type {
#[doc =
"Return type of the [`json_extract_path_text_1()`](fn@super::json_extract_path_text_1) SQL function."]
pub type json_extract_path_text_1<json, text_1> =
super::json_extract_path_text_1<<json as
diesel::expression::Expression>::SqlType,
<text_1 as diesel::expression::Expression>::SqlType, json, text_1>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_extract_path_text_1_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_extract_path_text_1<J, T1, json, text_1> {
pub(in super) json: json,
pub(in super) text_1: text_1,
pub(in super) J: ::core::marker::PhantomData<J>,
pub(in super) T1: ::core::marker::PhantomData<T1>,
}
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<J, T1, json, text_1, __Rhs> ::core::ops::Add<__Rhs> for
json_extract_path_text_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Sub<__Rhs> for
json_extract_path_text_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Mul<__Rhs> for
json_extract_path_text_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Div<__Rhs> for
json_extract_path_text_1<J, T1, json, text_1> 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<J: ::core::fmt::Debug, T1: ::core::fmt::Debug,
json: ::core::fmt::Debug, text_1: ::core::fmt::Debug>
::core::fmt::Debug for json_extract_path_text_1<J, T1, json, text_1> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"json_extract_path_text_1", "json", &self.json, "text_1",
&self.text_1, "J", &self.J, "T1", &&self.T1)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, T1: ::core::clone::Clone,
json: ::core::clone::Clone, text_1: ::core::clone::Clone>
::core::clone::Clone for json_extract_path_text_1<J, T1, json, text_1>
{
#[inline]
fn clone(&self) -> json_extract_path_text_1<J, T1, json, text_1> {
json_extract_path_text_1 {
json: ::core::clone::Clone::clone(&self.json),
text_1: ::core::clone::Clone::clone(&self.text_1),
J: ::core::clone::Clone::clone(&self.J),
T1: ::core::clone::Clone::clone(&self.T1),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, T1: ::core::marker::Copy,
json: ::core::marker::Copy, text_1: ::core::marker::Copy>
::core::marker::Copy for json_extract_path_text_1<J, T1, json, text_1>
{
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
T1: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
text_1: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_extract_path_text_1<J, T1, json, text_1> {
type QueryId =
json_extract_path_text_1<<J as
diesel::query_builder::QueryId>::QueryId,
<T1 as diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<text_1 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<T1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<text_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_extract_path_text_1()`](fn@json_extract_path_text_1)"]
pub type HelperType<J, T1, json, text_1> =
json_extract_path_text_1<J, T1, <json as AsExpression<J>>::Expression,
<text_1 as AsExpression<T1>>::Expression>;
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1> Expression for
json_extract_path_text_1<J, T1, json, text_1> where
(json, text_1): Expression {
type SqlType = Nullable<Text>;
}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_extract_path_text_1<J, T1, json, text_1> where
json: SelectableExpression<__DieselInternal>,
text_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1, __DieselInternal>
AppearsOnTable<__DieselInternal> for
json_extract_path_text_1<J, T1, json, text_1> where
json: AppearsOnTable<__DieselInternal>,
text_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1, __DieselInternal>
FunctionFragment<__DieselInternal> for
json_extract_path_text_1<J, T1, json, text_1> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
text_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_extract_path_text";
#[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;
}
if !self.text_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1> QueryFragment<crate::pg::Pg> for
json_extract_path_text_1<J, T1, json, text_1> where
json: QueryFragment<crate::pg::Pg>,
text_1: 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, text_1>(json, text_1);
const _: () =
{
use diesel;
impl<json, text_1, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, text_1> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
text_1: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<text_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1, __DieselInternal>
ValidGrouping<__DieselInternal> for
json_extract_path_text_1<J, T1, json, text_1> where
__Derived<json, text_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, text_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Extracts JSON sub-object at the specified path as text. (This is functionally equivalent to the #>> operator.)"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`json_extract_path_text_0`, `json_extract_path_text_1`, ... `json_extract_path_text_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "json_extract_path_text")]
#[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_extract_path_text_1, json_extract_path_text_2};"]
#[doc = " # use diesel::sql_types::{Json, Nullable, Text};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let expected = Some(String::from(\"{\\\"f5\\\":99,\\\"f6\\\":\\\"foo\\\"}\"));"]
#[doc =
" let result = diesel::select(json_extract_path_text_1::<Json, Text, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " ))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc = " let expected = Some(String::from(\"foo\"));"]
#[doc =
" let result = diesel::select(json_extract_path_text_2::<Json, Text, Text, _, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " \"f6\""]
#[doc = " ))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_extract_path_text_1::<Nullable<Json>, Text, _, _>(None::<serde_json::Value>, \"f4\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<String>, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_extract_path_text_2::<Json, Nullable<Text>, Text, _, _, _>(json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}), None::<String>, \"f6\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<String>, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_extract_path_text_2<J: JsonOrNullableJson + SingleValue,
T1: SingleValue + TextOrNullableText, T2: SingleValue +
TextOrNullableText, json, text_1,
text_2>(json: json, text_1: text_1, text_2: text_2)
-> json_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
json: diesel::expression::AsExpression<J>,
text_1: diesel::expression::AsExpression<T1>,
text_2: diesel::expression::AsExpression<T2> {
json_extract_path_text_2_utils::json_extract_path_text_2 {
json: json.as_expression(),
text_1: text_1.as_expression(),
text_2: text_2.as_expression(),
J: ::core::marker::PhantomData,
T1: ::core::marker::PhantomData,
T2: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_extract_path_text_2()`](fn@json_extract_path_text_2)"]
pub type json_extract_path_text_2<J, T1, T2, json, text_1, text_2> =
json_extract_path_text_2_utils::json_extract_path_text_2<J, T1, T2,
<json as diesel::expression::AsExpression<J>>::Expression,
<text_1 as diesel::expression::AsExpression<T1>>::Expression,
<text_2 as diesel::expression::AsExpression<T2>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_extract_path_text_2_return_type {
#[doc =
"Return type of the [`json_extract_path_text_2()`](fn@super::json_extract_path_text_2) SQL function."]
pub type json_extract_path_text_2<json, text_1, text_2> =
super::json_extract_path_text_2<<json as
diesel::expression::Expression>::SqlType,
<text_1 as diesel::expression::Expression>::SqlType,
<text_2 as diesel::expression::Expression>::SqlType, json, text_1,
text_2>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_extract_path_text_2_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_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
pub(in super) json: json,
pub(in super) text_1: text_1,
pub(in super) text_2: text_2,
pub(in super) J: ::core::marker::PhantomData<J>,
pub(in super) T1: ::core::marker::PhantomData<T1>,
pub(in super) T2: ::core::marker::PhantomData<T2>,
}
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Add<__Rhs> for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2>
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Sub<__Rhs> for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2>
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Mul<__Rhs> for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2>
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Div<__Rhs> for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2>
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<J: ::core::fmt::Debug, T1: ::core::fmt::Debug,
T2: ::core::fmt::Debug, json: ::core::fmt::Debug,
text_1: ::core::fmt::Debug, text_2: ::core::fmt::Debug>
::core::fmt::Debug for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["json", "text_1", "text_2", "J", "T1", "T2"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.json, &self.text_1, &self.text_2, &self.J, &self.T1,
&&self.T2];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"json_extract_path_text_2", names, values)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, T1: ::core::clone::Clone,
T2: ::core::clone::Clone, json: ::core::clone::Clone,
text_1: ::core::clone::Clone, text_2: ::core::clone::Clone>
::core::clone::Clone for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
#[inline]
fn clone(&self)
-> json_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
json_extract_path_text_2 {
json: ::core::clone::Clone::clone(&self.json),
text_1: ::core::clone::Clone::clone(&self.text_1),
text_2: ::core::clone::Clone::clone(&self.text_2),
J: ::core::clone::Clone::clone(&self.J),
T1: ::core::clone::Clone::clone(&self.T1),
T2: ::core::clone::Clone::clone(&self.T2),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, T1: ::core::marker::Copy,
T2: ::core::marker::Copy, json: ::core::marker::Copy,
text_1: ::core::marker::Copy, text_2: ::core::marker::Copy>
::core::marker::Copy for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
T1: diesel::query_builder::QueryId,
T2: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
text_1: diesel::query_builder::QueryId,
text_2: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
type QueryId =
json_extract_path_text_2<<J as
diesel::query_builder::QueryId>::QueryId,
<T1 as diesel::query_builder::QueryId>::QueryId,
<T2 as diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<text_1 as diesel::query_builder::QueryId>::QueryId,
<text_2 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T2 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_2 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<T1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<T2 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<text_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<text_2 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_extract_path_text_2()`](fn@json_extract_path_text_2)"]
pub type HelperType<J, T1, T2, json, text_1, text_2> =
json_extract_path_text_2<J, T1, T2,
<json as AsExpression<J>>::Expression,
<text_1 as AsExpression<T1>>::Expression,
<text_2 as AsExpression<T2>>::Expression>;
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2> Expression for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
(json, text_1, text_2): Expression {
type SqlType = Nullable<Text>;
}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
json: SelectableExpression<__DieselInternal>,
text_1: SelectableExpression<__DieselInternal>,
text_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2, __DieselInternal> AppearsOnTable<__DieselInternal> for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
json: AppearsOnTable<__DieselInternal>,
text_1: AppearsOnTable<__DieselInternal>,
text_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2, __DieselInternal> FunctionFragment<__DieselInternal>
for json_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
text_1: QueryFragment<__DieselInternal>,
text_2: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_extract_path_text";
#[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;
}
if !self.text_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.text_2.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_2.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2> QueryFragment<crate::pg::Pg> for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
json: QueryFragment<crate::pg::Pg>,
text_1: QueryFragment<crate::pg::Pg>,
text_2: 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, text_1, text_2>(json, text_1, text_2);
const _: () =
{
use diesel;
impl<json, text_1, text_2, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, text_1, text_2> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
text_1: diesel::expression::ValidGrouping<__GroupByClause>,
text_2: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<text_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<text_2
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
as
diesel::expression::MixedAggregates<<text_2 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJson + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2, __DieselInternal> ValidGrouping<__DieselInternal> for
json_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
__Derived<json, text_1, text_2>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, text_1, text_2> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[allow(unused_imports)]
#[doc(inline)]
mod __json_extract_path_text_return_types {
#[doc(inline)]
pub use super::__json_extract_path_text_1_return_type::*;
#[doc(inline)]
pub use super::__json_extract_path_text_2_return_type::*;
}
#[doc =
" Extracts JSON sub-object at the specified path as text. (This is functionally equivalent to the #>> operator.)"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`jsonb_extract_path_text_0`, `jsonb_extract_path_text_1`, ... `jsonb_extract_path_text_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "jsonb_extract_path_text")]
#[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_extract_path_text_1, jsonb_extract_path_text_2};"]
#[doc = " # use diesel::sql_types::{Jsonb, Nullable, Text};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let expected = Some(String::from(\"{\\\"f5\\\": 99, \\\"f6\\\": \\\"foo\\\"}\"));"]
#[doc =
" let result = diesel::select(jsonb_extract_path_text_1::<Jsonb, Text, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " ))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc = " let expected = Some(String::from(\"foo\"));"]
#[doc =
" let result = diesel::select(jsonb_extract_path_text_2::<Jsonb, Text, Text, _, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " \"f6\""]
#[doc = " ))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_extract_path_text_1::<Nullable<Jsonb>, Text, _, _>(None::<serde_json::Value>, \"f4\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<String>, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_extract_path_text_2::<Jsonb, Nullable<Text>, Text, _, _, _>(json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}), None::<String>, \"f6\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<String>, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_extract_path_text_1<J: JsonbOrNullableJsonb + SingleValue,
T1: SingleValue + TextOrNullableText, json,
text_1>(json: json, text_1: text_1)
-> jsonb_extract_path_text_1<J, T1, json, text_1> where
json: diesel::expression::AsExpression<J>,
text_1: diesel::expression::AsExpression<T1> {
jsonb_extract_path_text_1_utils::jsonb_extract_path_text_1 {
json: json.as_expression(),
text_1: text_1.as_expression(),
J: ::core::marker::PhantomData,
T1: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_extract_path_text_1()`](fn@jsonb_extract_path_text_1)"]
pub type jsonb_extract_path_text_1<J, T1, json, text_1> =
jsonb_extract_path_text_1_utils::jsonb_extract_path_text_1<J, T1,
<json as diesel::expression::AsExpression<J>>::Expression,
<text_1 as diesel::expression::AsExpression<T1>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_extract_path_text_1_return_type {
#[doc =
"Return type of the [`jsonb_extract_path_text_1()`](fn@super::jsonb_extract_path_text_1) SQL function."]
pub type jsonb_extract_path_text_1<json, text_1> =
super::jsonb_extract_path_text_1<<json as
diesel::expression::Expression>::SqlType,
<text_1 as diesel::expression::Expression>::SqlType, json, text_1>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_extract_path_text_1_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_extract_path_text_1<J, T1, json, text_1> {
pub(in super) json: json,
pub(in super) text_1: text_1,
pub(in super) J: ::core::marker::PhantomData<J>,
pub(in super) T1: ::core::marker::PhantomData<T1>,
}
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<J, T1, json, text_1, __Rhs> ::core::ops::Add<__Rhs> for
jsonb_extract_path_text_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Sub<__Rhs> for
jsonb_extract_path_text_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Mul<__Rhs> for
jsonb_extract_path_text_1<J, T1, json, text_1> 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<J, T1, json, text_1, __Rhs> ::core::ops::Div<__Rhs> for
jsonb_extract_path_text_1<J, T1, json, text_1> 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<J: ::core::fmt::Debug, T1: ::core::fmt::Debug,
json: ::core::fmt::Debug, text_1: ::core::fmt::Debug>
::core::fmt::Debug for jsonb_extract_path_text_1<J, T1, json, text_1>
{
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"jsonb_extract_path_text_1", "json", &self.json, "text_1",
&self.text_1, "J", &self.J, "T1", &&self.T1)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, T1: ::core::clone::Clone,
json: ::core::clone::Clone, text_1: ::core::clone::Clone>
::core::clone::Clone for
jsonb_extract_path_text_1<J, T1, json, text_1> {
#[inline]
fn clone(&self) -> jsonb_extract_path_text_1<J, T1, json, text_1> {
jsonb_extract_path_text_1 {
json: ::core::clone::Clone::clone(&self.json),
text_1: ::core::clone::Clone::clone(&self.text_1),
J: ::core::clone::Clone::clone(&self.J),
T1: ::core::clone::Clone::clone(&self.T1),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, T1: ::core::marker::Copy,
json: ::core::marker::Copy, text_1: ::core::marker::Copy>
::core::marker::Copy for
jsonb_extract_path_text_1<J, T1, json, text_1> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
T1: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
text_1: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_extract_path_text_1<J, T1, json, text_1> {
type QueryId =
jsonb_extract_path_text_1<<J as
diesel::query_builder::QueryId>::QueryId,
<T1 as diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<text_1 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<T1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<text_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`jsonb_extract_path_text_1()`](fn@jsonb_extract_path_text_1)"]
pub type HelperType<J, T1, json, text_1> =
jsonb_extract_path_text_1<J, T1,
<json as AsExpression<J>>::Expression,
<text_1 as AsExpression<T1>>::Expression>;
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1> Expression for
jsonb_extract_path_text_1<J, T1, json, text_1> where
(json, text_1): Expression {
type SqlType = Nullable<Text>;
}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_extract_path_text_1<J, T1, json, text_1> where
json: SelectableExpression<__DieselInternal>,
text_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1, __DieselInternal>
AppearsOnTable<__DieselInternal> for
jsonb_extract_path_text_1<J, T1, json, text_1> where
json: AppearsOnTable<__DieselInternal>,
text_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1, __DieselInternal>
FunctionFragment<__DieselInternal> for
jsonb_extract_path_text_1<J, T1, json, text_1> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
text_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_extract_path_text";
#[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;
}
if !self.text_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1> QueryFragment<crate::pg::Pg> for
jsonb_extract_path_text_1<J, T1, json, text_1> where
json: QueryFragment<crate::pg::Pg>,
text_1: 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, text_1>(json, text_1);
const _: () =
{
use diesel;
impl<json, text_1, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, text_1> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
text_1: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<text_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, json, text_1, __DieselInternal>
ValidGrouping<__DieselInternal> for
jsonb_extract_path_text_1<J, T1, json, text_1> where
__Derived<json, text_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, text_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Extracts JSON sub-object at the specified path as text. (This is functionally equivalent to the #>> operator.)"]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = r""]
#[doc = r" # Variadic functions"]
#[doc = r""]
#[doc =
r" This function is variadic in SQL, so there's a family of functions"]
#[doc = r" on a diesel side:"]
#[doc = r""]
#[doc =
"`jsonb_extract_path_text_0`, `jsonb_extract_path_text_1`, ... `jsonb_extract_path_text_n`"]
#[doc = r""]
#[doc =
r" Here, the postfix number indicates repetitions of variadic arguments."]
#[doc = r" To use this function, the appropriate version with the correct"]
#[doc = r" argument count must be selected."]
#[doc = r""]
#[doc = r" ## Controlling the generation of variadic function variants"]
#[doc = r""]
#[doc =
r" By default, only variants with 0, 1, and 2 repetitions of variadic"]
#[doc = r" arguments are generated. To generate more variants, set the"]
#[doc =
r" `DIESEL_VARIADIC_FUNCTION_ARGS` environment variable to the desired"]
#[doc = r" number of variants."]
#[doc = r""]
#[doc =
r" For a greater convenience this environment variable can also be set"]
#[doc = r" in a `.cargo/config.toml` file as described in the"]
#[doc =
r" [cargo documentation](https://doc.rust-lang.org/cargo/reference/config.html#env)."]
#[doc(alias = "jsonb_extract_path_text")]
#[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_extract_path_text_1, jsonb_extract_path_text_2};"]
#[doc = " # use diesel::sql_types::{Jsonb, Nullable, Text};"]
#[doc = " # use serde_json::{json,Value};"]
#[doc = " # use diesel::dsl::sql;"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let expected = Some(String::from(\"{\\\"f5\\\": 99, \\\"f6\\\": \\\"foo\\\"}\"));"]
#[doc =
" let result = diesel::select(jsonb_extract_path_text_1::<Jsonb, Text, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " ))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc = " let expected = Some(String::from(\"foo\"));"]
#[doc =
" let result = diesel::select(jsonb_extract_path_text_2::<Jsonb, Text, Text, _, _, _>("]
#[doc = " json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}),"]
#[doc = " \"f4\","]
#[doc = " \"f6\""]
#[doc = " ))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(expected, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_extract_path_text_1::<Nullable<Jsonb>, Text, _, _>(None::<serde_json::Value>, \"f4\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<String>, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_extract_path_text_2::<Jsonb, Nullable<Text>, Text, _, _, _>(json!({\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"foo\"}}), None::<String>, \"f6\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None::<String>, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_extract_path_text_2<J: JsonbOrNullableJsonb + SingleValue,
T1: SingleValue + TextOrNullableText, T2: SingleValue +
TextOrNullableText, json, text_1,
text_2>(json: json, text_1: text_1, text_2: text_2)
-> jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
json: diesel::expression::AsExpression<J>,
text_1: diesel::expression::AsExpression<T1>,
text_2: diesel::expression::AsExpression<T2> {
jsonb_extract_path_text_2_utils::jsonb_extract_path_text_2 {
json: json.as_expression(),
text_1: text_1.as_expression(),
text_2: text_2.as_expression(),
J: ::core::marker::PhantomData,
T1: ::core::marker::PhantomData,
T2: ::core::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`jsonb_extract_path_text_2()`](fn@jsonb_extract_path_text_2)"]
pub type jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> =
jsonb_extract_path_text_2_utils::jsonb_extract_path_text_2<J, T1, T2,
<json as diesel::expression::AsExpression<J>>::Expression,
<text_1 as diesel::expression::AsExpression<T1>>::Expression,
<text_2 as diesel::expression::AsExpression<T2>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_extract_path_text_2_return_type {
#[doc =
"Return type of the [`jsonb_extract_path_text_2()`](fn@super::jsonb_extract_path_text_2) SQL function."]
pub type jsonb_extract_path_text_2<json, text_1, text_2> =
super::jsonb_extract_path_text_2<<json as
diesel::expression::Expression>::SqlType,
<text_1 as diesel::expression::Expression>::SqlType,
<text_2 as diesel::expression::Expression>::SqlType, json, text_1,
text_2>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_extract_path_text_2_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_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
pub(in super) json: json,
pub(in super) text_1: text_1,
pub(in super) text_2: text_2,
pub(in super) J: ::core::marker::PhantomData<J>,
pub(in super) T1: ::core::marker::PhantomData<T1>,
pub(in super) T2: ::core::marker::PhantomData<T2>,
}
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Add<__Rhs> for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2>
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Sub<__Rhs> for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2>
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Mul<__Rhs> for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2>
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<J, T1, T2, json, text_1, text_2, __Rhs>
::core::ops::Div<__Rhs> for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2>
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<J: ::core::fmt::Debug, T1: ::core::fmt::Debug,
T2: ::core::fmt::Debug, json: ::core::fmt::Debug,
text_1: ::core::fmt::Debug, text_2: ::core::fmt::Debug>
::core::fmt::Debug for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["json", "text_1", "text_2", "J", "T1", "T2"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.json, &self.text_1, &self.text_2, &self.J, &self.T1,
&&self.T2];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"jsonb_extract_path_text_2", names, values)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, T1: ::core::clone::Clone,
T2: ::core::clone::Clone, json: ::core::clone::Clone,
text_1: ::core::clone::Clone, text_2: ::core::clone::Clone>
::core::clone::Clone for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
#[inline]
fn clone(&self)
-> jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
jsonb_extract_path_text_2 {
json: ::core::clone::Clone::clone(&self.json),
text_1: ::core::clone::Clone::clone(&self.text_1),
text_2: ::core::clone::Clone::clone(&self.text_2),
J: ::core::clone::Clone::clone(&self.J),
T1: ::core::clone::Clone::clone(&self.T1),
T2: ::core::clone::Clone::clone(&self.T2),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, T1: ::core::marker::Copy,
T2: ::core::marker::Copy, json: ::core::marker::Copy,
text_1: ::core::marker::Copy, text_2: ::core::marker::Copy>
::core::marker::Copy for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
T1: diesel::query_builder::QueryId,
T2: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
text_1: diesel::query_builder::QueryId,
text_2: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> {
type QueryId =
jsonb_extract_path_text_2<<J as
diesel::query_builder::QueryId>::QueryId,
<T1 as diesel::query_builder::QueryId>::QueryId,
<T2 as diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<text_1 as diesel::query_builder::QueryId>::QueryId,
<text_2 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T1 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<T2 as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<text_2 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<T1 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<T2 as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<text_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<text_2 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`jsonb_extract_path_text_2()`](fn@jsonb_extract_path_text_2)"]
pub type HelperType<J, T1, T2, json, text_1, text_2> =
jsonb_extract_path_text_2<J, T1, T2,
<json as AsExpression<J>>::Expression,
<text_1 as AsExpression<T1>>::Expression,
<text_2 as AsExpression<T2>>::Expression>;
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2> Expression for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
(json, text_1, text_2): Expression {
type SqlType = Nullable<Text>;
}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
json: SelectableExpression<__DieselInternal>,
text_1: SelectableExpression<__DieselInternal>,
text_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2, __DieselInternal> AppearsOnTable<__DieselInternal> for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
json: AppearsOnTable<__DieselInternal>,
text_1: AppearsOnTable<__DieselInternal>,
text_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2, __DieselInternal> FunctionFragment<__DieselInternal>
for jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
text_1: QueryFragment<__DieselInternal>,
text_2: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_extract_path_text";
#[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;
}
if !self.text_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.text_2.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.text_2.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2> QueryFragment<crate::pg::Pg> for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
json: QueryFragment<crate::pg::Pg>,
text_1: QueryFragment<crate::pg::Pg>,
text_2: 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, text_1, text_2>(json, text_1, text_2);
const _: () =
{
use diesel;
impl<json, text_1, text_2, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, text_1, text_2> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
text_1: diesel::expression::ValidGrouping<__GroupByClause>,
text_2: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<text_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<text_2
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<text_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
as
diesel::expression::MixedAggregates<<text_2 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonbOrNullableJsonb + SingleValue, T1: SingleValue +
TextOrNullableText, T2: SingleValue + TextOrNullableText, json,
text_1, text_2, __DieselInternal> ValidGrouping<__DieselInternal> for
jsonb_extract_path_text_2<J, T1, T2, json, text_1, text_2> where
__Derived<json, text_1, text_2>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, text_1, text_2> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[allow(unused_imports)]
#[doc(inline)]
mod __jsonb_extract_path_text_return_types {
#[doc(inline)]
pub use super::__jsonb_extract_path_text_1_return_type::*;
#[doc(inline)]
pub use super::__jsonb_extract_path_text_2_return_type::*;
}
#[allow(unused_imports)]
#[doc(hidden)]
mod return_type_helpers {
#[doc(inline)]
pub use super::__abbrev_return_type::*;
#[doc(inline)]
pub use super::__broadcast_return_type::*;
#[doc(inline)]
pub use super::__family_return_type::*;
#[doc(inline)]
pub use super::__host_return_type::*;
#[doc(inline)]
pub use super::__hostmask_return_type::*;
#[doc(inline)]
pub use super::__inet_merge_return_type::*;
#[doc(inline)]
pub use super::__inet_same_family_return_type::*;
#[doc(inline)]
pub use super::__masklen_return_type::*;
#[doc(inline)]
pub use super::__netmask_return_type::*;
#[doc(inline)]
pub use super::__network_return_type::*;
#[doc(inline)]
pub use super::__set_masklen_return_type::*;
#[doc(inline)]
pub use super::__lower_return_type::*;
#[doc(inline)]
pub use super::__upper_return_type::*;
#[doc(inline)]
pub use super::__isempty_return_type::*;
#[doc(inline)]
pub use super::__lower_inc_return_type::*;
#[doc(inline)]
pub use super::__upper_inc_return_type::*;
#[doc(inline)]
pub use super::__lower_inf_return_type::*;
#[doc(inline)]
pub use super::__upper_inf_return_type::*;
#[doc(inline)]
pub use super::__range_merge_return_type::*;
#[doc(inline)]
pub use super::__multirange_merge_return_type::*;
#[doc(inline)]
pub use super::__int4range_return_type::*;
#[doc(inline)]
pub use super::__int8range_return_type::*;
#[doc(inline)]
pub use super::__numrange_return_type::*;
#[doc(inline)]
pub use super::__tsrange_return_type::*;
#[doc(inline)]
pub use super::__tstzrange_return_type::*;
#[doc(inline)]
pub use super::__daterange_return_type::*;
#[doc(inline)]
pub use super::__array_append_return_type::*;
#[doc(inline)]
pub use super::__array_replace_return_type::*;
#[doc(inline)]
pub use super::__array_dims_return_type::*;
#[doc(inline)]
pub use super::__array_prepend_return_type::*;
#[doc(inline)]
pub use super::__array_remove_return_type::*;
#[doc(inline)]
pub use super::__array_to_string_with_null_string_return_type::*;
#[doc(inline)]
pub use super::__array_to_string_return_type::*;
#[doc(inline)]
pub use super::__cardinality_return_type::*;
#[doc(inline)]
pub use super::__trim_array_return_type::*;
#[doc(inline)]
pub use super::__array_cat_return_type::*;
#[doc(inline)]
pub use super::__array_length_return_type::*;
#[doc(inline)]
pub use super::__array_fill_return_type::*;
#[doc(inline)]
pub use super::__array_fill_with_lower_bound_return_type::*;
#[doc(inline)]
pub use super::__array_lower_return_type::*;
#[doc(inline)]
pub use super::__array_position_return_type::*;
#[doc(inline)]
pub use super::__array_position_with_subscript_return_type::*;
#[doc(inline)]
pub use super::__array_positions_return_type::*;
#[doc(inline)]
pub use super::__array_ndims_return_type::*;
#[doc(inline)]
pub use super::__array_upper_return_type::*;
#[doc(inline)]
pub use super::__array_shuffle_return_type::*;
#[doc(inline)]
pub use super::__array_sample_return_type::*;
#[doc(inline)]
pub use super::__array_to_json_return_type::*;
#[doc(inline)]
pub use super::__to_json_return_type::*;
#[doc(inline)]
pub use super::__to_jsonb_return_type::*;
#[doc(inline)]
pub use super::__json_object_return_type::*;
#[doc(inline)]
pub use super::__json_object_with_keys_and_values_return_type::*;
#[doc(inline)]
pub use super::__json_typeof_return_type::*;
#[doc(inline)]
pub use super::__jsonb_typeof_return_type::*;
#[doc(inline)]
pub use super::__jsonb_pretty_return_type::*;
#[doc(inline)]
pub use super::__json_strip_nulls_return_type::*;
#[doc(inline)]
pub use super::__jsonb_strip_nulls_return_type::*;
#[doc(inline)]
pub use super::__json_array_length_return_type::*;
#[doc(inline)]
pub use super::__jsonb_array_length_return_type::*;
#[doc(inline)]
pub use super::__jsonb_object_return_type::*;
#[doc(inline)]
pub use super::__jsonb_object_with_keys_and_values_return_type::*;
#[doc(inline)]
pub use super::__row_to_json_return_type::*;
#[doc(inline)]
pub use super::__json_populate_record_return_type::*;
#[doc(inline)]
pub use super::__jsonb_populate_record_return_type::*;
#[doc(inline)]
pub use super::__jsonb_set_return_type::*;
#[doc(inline)]
pub use super::__jsonb_set_create_if_missing_return_type::*;
#[doc(inline)]
pub use super::__jsonb_set_lax_return_type::*;
#[doc(inline)]
pub use super::__jsonb_insert_return_type::*;
#[doc(inline)]
pub use super::__jsonb_insert_with_insert_after_return_type::*;
#[doc(inline)]
pub use super::__json_build_array_return_types::*;
#[doc(inline)]
pub use super::__jsonb_build_array_return_types::*;
#[doc(inline)]
pub use super::__json_extract_path_return_types::*;
#[doc(inline)]
pub use super::__jsonb_extract_path_return_types::*;
#[doc(inline)]
pub use super::__json_extract_path_text_return_types::*;
#[doc(inline)]
pub use super::__jsonb_extract_path_text_return_types::*;
}#[declare_sql_function(generate_return_type_helpers = true)]
20#[backends(crate::pg::Pg)]
21extern "SQL" {
22 #[cfg(feature = "postgres_backend")]
24 fn abbrev<T: InetOrCidr + SingleValue>(addr: T) -> Text;
25
26 #[cfg(feature = "postgres_backend")]
28 fn broadcast<T: InetOrCidr + SingleValue>(addr: T) -> Inet;
29
30 #[cfg(feature = "postgres_backend")]
32 fn family<T: InetOrCidr + SingleValue>(addr: T) -> Integer;
33
34 #[cfg(feature = "postgres_backend")]
36 fn host<T: InetOrCidr + SingleValue>(addr: T) -> Text;
37
38 #[cfg(feature = "postgres_backend")]
40 fn hostmask<T: InetOrCidr + SingleValue>(addr: T) -> Inet;
41
42 #[cfg(feature = "postgres_backend")]
44 fn inet_merge<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue>(a: T, b: U) -> Cidr;
45
46 #[cfg(feature = "postgres_backend")]
48 fn inet_same_family<T: InetOrCidr + SingleValue, U: InetOrCidr + SingleValue>(
49 a: T,
50 b: U,
51 ) -> Bool;
52
53 #[cfg(feature = "postgres_backend")]
55 fn masklen<T: InetOrCidr + SingleValue>(addr: T) -> Integer;
56
57 #[cfg(feature = "postgres_backend")]
59 fn netmask<T: InetOrCidr + SingleValue>(addr: T) -> Inet;
60
61 #[cfg(feature = "postgres_backend")]
64 fn network<T: InetOrCidr + SingleValue>(addr: T) -> Cidr;
65
66 #[cfg(feature = "postgres_backend")]
70 fn set_masklen<T: InetOrCidr + SingleValue>(addr: T, len: Integer) -> T;
71
72 #[cfg(feature = "postgres_backend")]
108 fn lower<R: MultirangeOrRangeMaybeNullable + SingleValue>(range: R) -> Nullable<R::Inner>;
109
110 #[cfg(feature = "postgres_backend")]
146 fn upper<R: MultirangeOrRangeMaybeNullable + SingleValue>(range: R) -> Nullable<R::Inner>;
147
148 #[cfg(feature = "postgres_backend")]
184 fn isempty<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
185 range: R,
186 ) -> R::Out;
187
188 #[cfg(feature = "postgres_backend")]
225 fn lower_inc<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
226 range: R,
227 ) -> R::Out;
228
229 #[cfg(feature = "postgres_backend")]
263 fn upper_inc<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
264 range: R,
265 ) -> R::Out;
266
267 #[cfg(feature = "postgres_backend")]
304 fn lower_inf<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
305 range: R,
306 ) -> R::Out;
307
308 #[cfg(feature = "postgres_backend")]
345 fn upper_inf<R: MultirangeOrRangeMaybeNullable + SingleValue + MaybeNullableValue<Bool>>(
346 range: R,
347 ) -> R::Out;
348
349 #[cfg(feature = "postgres_backend")]
395 fn range_merge<
396 R1: RangeOrNullableRange + SingleValue,
397 R2: RangeOrNullableRange<Inner = R1::Inner>
398 + SingleValue
399 + CombinedNullableValue<R1, Range<R1::Inner>>,
400 >(
401 lhs: R1,
402 rhs: R2,
403 ) -> R2::Out;
404
405 #[cfg(feature = "postgres_backend")]
438 #[sql_name = "range_merge"]
439 fn multirange_merge<R: MultirangeOrNullableMultirange + SingleValue>(multirange: R)
440 -> R::Range;
441
442 #[cfg(feature = "postgres_backend")]
486 fn int4range(
487 lower: Nullable<Integer>,
488 upper: Nullable<Integer>,
489 bound: RangeBoundEnum,
490 ) -> Int4range;
491
492 #[cfg(feature = "postgres_backend")]
536 fn int8range(
537 lower: Nullable<BigInt>,
538 upper: Nullable<BigInt>,
539 bound: RangeBoundEnum,
540 ) -> Int8range;
541
542 #[cfg(feature = "postgres_backend")]
589 fn numrange(
590 lower: Nullable<Numeric>,
591 upper: Nullable<Numeric>,
592 bound: RangeBoundEnum,
593 ) -> Numrange;
594
595 #[cfg(feature = "postgres_backend")]
642 fn tsrange(
643 lower: Nullable<Timestamp>,
644 upper: Nullable<Timestamp>,
645 bound: RangeBoundEnum,
646 ) -> Tsrange;
647
648 #[cfg(feature = "postgres_backend")]
695 fn tstzrange(
696 lower: Nullable<Timestamptz>,
697 upper: Nullable<Timestamptz>,
698 bound: RangeBoundEnum,
699 ) -> Tstzrange;
700
701 #[cfg(feature = "postgres_backend")]
748 fn daterange(lower: Nullable<Date>, upper: Nullable<Date>, bound: RangeBoundEnum) -> Daterange;
749
750 #[cfg(feature = "postgres_backend")]
793 fn array_append<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue>(
794 a: Arr,
795 e: T,
796 ) -> Array<T>;
797
798 #[cfg(feature = "postgres_backend")]
849 fn array_replace<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue>(
850 a: Arr,
851 e: T,
852 r: T,
853 ) -> Arr;
854
855 #[cfg(feature = "postgres_backend")]
884 fn array_dims<Arr: ArrayOrNullableArray + SingleValue>(arr: Arr) -> Text;
885
886 #[cfg(feature = "postgres_backend")]
928 fn array_prepend<T: SingleValue, Arr: ArrayOrNullableArray<Inner = T> + SingleValue>(
929 e: T,
930 a: Arr,
931 ) -> Array<T>;
932
933 #[cfg(feature = "postgres_backend")]
969 fn array_remove<Arr: ArrayOrNullableArray<Inner = T> + SingleValue, T: SingleValue>(
970 a: Arr,
971 e: T,
972 ) -> Arr;
973
974 #[cfg(feature = "postgres_backend")]
1030 #[sql_name = "array_to_string"]
1031 fn array_to_string_with_null_string<Arr: ArrayOrNullableArray + SingleValue>(
1032 array: Arr,
1033 del: Text,
1034 null: Text,
1035 ) -> Text;
1036
1037 #[cfg(feature = "postgres_backend")]
1083 fn array_to_string<Arr: ArrayOrNullableArray + SingleValue>(array: Arr, del: Text) -> Text;
1084
1085 #[cfg(feature = "postgres_backend")]
1118 fn cardinality<Arr: ArrayOrNullableArray + SingleValue + MaybeNullableValue<Integer>>(
1119 a: Arr,
1120 ) -> Arr::Out;
1121
1122 #[cfg(feature = "postgres_backend")]
1159 fn trim_array<Arr: ArrayOrNullableArray + SingleValue>(a: Arr, n: Integer) -> Arr;
1160
1161 #[cfg(feature = "postgres_backend")]
1190 fn array_cat<Arr: ArrayOrNullableArray + SingleValue>(a: Arr, b: Arr) -> Arr;
1191
1192 #[cfg(feature = "postgres_backend")]
1225 fn array_length<Arr: ArrayOrNullableArray + SingleValue>(
1226 array: Arr,
1227 dimension: Integer,
1228 ) -> Nullable<Integer>;
1229
1230 #[cfg(feature = "postgres_backend")]
1265 fn array_fill<E: SingleValue>(value: E, dim: Array<Integer>) -> Array<E>;
1266
1267 #[sql_name = "array_fill"]
1301 #[cfg(feature = "postgres_backend")]
1302 fn array_fill_with_lower_bound<E: SingleValue>(
1303 value: E,
1304 dim: Array<Integer>,
1305 lower_bound: Array<Integer>,
1306 ) -> Array<E>;
1307
1308 #[cfg(feature = "postgres_backend")]
1337 fn array_lower<Arr: ArrayOrNullableArray + SingleValue>(
1338 array: Arr,
1339 dimension: Integer,
1340 ) -> Nullable<Integer>;
1341
1342 #[cfg(feature = "postgres_backend")]
1387 fn array_position<Arr: ArrayOrNullableArray<Inner = E> + SingleValue, E: SingleValue>(
1388 a: Arr,
1389 elem: E,
1390 ) -> Nullable<Integer>;
1391
1392 #[sql_name = "array_position"]
1433 #[cfg(feature = "postgres_backend")]
1434 fn array_position_with_subscript<
1435 Arr: ArrayOrNullableArray<Inner = E> + SingleValue,
1436 E: SingleValue,
1437 >(
1438 a: Arr,
1439 elem: E,
1440 subscript: Integer,
1441 ) -> Nullable<Integer>;
1442
1443 #[cfg(feature = "postgres_backend")]
1483 fn array_positions<
1484 Arr: ArrayOrNullableArray<Inner = E> + SingleValue + MaybeNullableValue<Array<Integer>>,
1485 E: SingleValue,
1486 >(
1487 a: Arr,
1488 elem: E,
1489 ) -> Arr::Out;
1490
1491 #[cfg(feature = "postgres_backend")]
1520 fn array_ndims<Arr: ArrayOrNullableArray + SingleValue + MaybeNullableValue<Integer>>(
1521 arr: Arr,
1522 ) -> Arr::Out;
1523
1524 #[cfg(feature = "postgres_backend")]
1553 fn array_upper<Arr: ArrayOrNullableArray + SingleValue>(
1554 array: Arr,
1555 dimension: Integer,
1556 ) -> Nullable<Integer>;
1557
1558 #[cfg(feature = "postgres_backend")]
1583 fn array_shuffle<Arr: ArrayOrNullableArray + SingleValue>(array: Arr) -> Arr;
1584
1585 #[cfg(feature = "postgres_backend")]
1625 fn array_sample<Arr: ArrayOrNullableArray + SingleValue>(array: Arr, n: Integer) -> Arr;
1626
1627 #[cfg(feature = "postgres_backend")]
1668 fn array_to_json<Arr: ArrayOrNullableArray + MaybeNullableValue<Json>>(array: Arr) -> Arr::Out;
1669
1670 #[cfg(feature = "postgres_backend")]
1711 fn to_json<E: MaybeNullableValue<Json>>(e: E) -> E::Out;
1712
1713 #[cfg(feature = "postgres_backend")]
1754 fn to_jsonb<E: MaybeNullableValue<Jsonb>>(e: E) -> E::Out;
1755
1756 #[cfg(feature = "postgres_backend")]
1798 fn json_object<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Json>>(
1799 text_array: Arr,
1800 ) -> Arr::Out;
1801
1802 #[sql_name = "json_object"]
1842 #[cfg(feature = "postgres_backend")]
1843 fn json_object_with_keys_and_values<
1844 Arr1: TextArrayOrNullableTextArray + SingleValue,
1845 Arr2: TextArrayOrNullableTextArray + CombinedNullableValue<Arr1, Json>,
1846 >(
1847 keys: Arr1,
1848 values: Arr2,
1849 ) -> Arr2::Out;
1850
1851 #[cfg(feature = "postgres_backend")]
1907 fn json_typeof<E: JsonOrNullableJson + SingleValue + MaybeNullableValue<Text>>(e: E) -> E::Out;
1908
1909 #[cfg(feature = "postgres_backend")]
1965 fn jsonb_typeof<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>>(
1966 e: E,
1967 ) -> E::Out;
1968
1969 #[cfg(feature = "postgres_backend")]
2042 fn jsonb_pretty<E: JsonbOrNullableJsonb + SingleValue + MaybeNullableValue<Text>>(
2043 e: E,
2044 ) -> E::Out;
2045
2046 #[cfg(feature = "postgres_backend")]
2089 fn json_strip_nulls<E: JsonOrNullableJson + SingleValue>(json: E) -> E;
2090
2091 #[cfg(feature = "postgres_backend")]
2135 fn jsonb_strip_nulls<E: JsonbOrNullableJsonb + SingleValue>(jsonb: E) -> E;
2136
2137 #[cfg(feature = "postgres_backend")]
2173 fn json_array_length<E: JsonOrNullableJson + MaybeNullableValue<Integer>>(json: E) -> E::Out;
2174
2175 #[cfg(feature = "postgres_backend")]
2211 fn jsonb_array_length<E: JsonbOrNullableJsonb + MaybeNullableValue<Integer>>(
2212 jsonb: E,
2213 ) -> E::Out;
2214 #[cfg(feature = "postgres_backend")]
2264 fn jsonb_object<Arr: TextArrayOrNullableTextArray + MaybeNullableValue<Jsonb>>(
2265 text_array: Arr,
2266 ) -> Arr::Out;
2267
2268 #[sql_name = "jsonb_object"]
2308 #[cfg(feature = "postgres_backend")]
2309 fn jsonb_object_with_keys_and_values<
2310 Arr1: TextArrayOrNullableTextArray + SingleValue,
2311 Arr2: TextArrayOrNullableTextArray + CombinedNullableValue<Arr1, Jsonb>,
2312 >(
2313 keys: Arr1,
2314 values: Arr2,
2315 ) -> Arr2::Out;
2316
2317 #[sql_name = "row_to_json"]
2356 #[cfg(feature = "postgres_backend")]
2357 fn row_to_json<R: RecordOrNullableRecord + MaybeNullableValue<Json>>(record: R) -> R::Out;
2358
2359 #[sql_name = "json_populate_record"]
2410 #[cfg(feature = "postgres_backend")]
2411 fn json_populate_record<
2412 B: RecordOrNullableRecord + SingleValue,
2413 J: JsonOrNullableJson + CombinedAllNullableValue<Json, B>,
2414 >(
2415 base: B,
2416 from_json: J,
2417 ) -> J::Out;
2418
2419 #[sql_name = "jsonb_populate_record"]
2470 #[cfg(feature = "postgres_backend")]
2471 fn jsonb_populate_record<
2472 B: RecordOrNullableRecord + SingleValue,
2473 J: JsonbOrNullableJsonb + CombinedAllNullableValue<Jsonb, B>,
2474 >(
2475 base: B,
2476 from_json: J,
2477 ) -> J::Out;
2478
2479 #[cfg(feature = "postgres_backend")]
2554 fn jsonb_set<
2555 E: JsonbOrNullableJsonb + SingleValue,
2556 Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2557 >(
2558 base: E,
2559 path: Arr,
2560 new_value: E,
2561 ) -> Arr::Out;
2562
2563 #[sql_name = "jsonb_set"]
2653 fn jsonb_set_create_if_missing<
2654 E: JsonbOrNullableJsonb + SingleValue,
2655 Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2656 >(
2657 base: E,
2658 path: Arr,
2659 new_value: E,
2660 create_if_missing: Bool,
2661 ) -> Arr::Out;
2662
2663 fn jsonb_set_lax<
2744 E: JsonbOrNullableJsonb + SingleValue,
2745 Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2746 >(
2747 base: E,
2748 path: Arr,
2749 new_value: E,
2750 create_if_missing: Bool,
2751 null_value_treatment: NullValueTreatmentEnum,
2752 ) -> Arr::Out;
2753
2754 fn jsonb_insert<
2804 E: JsonbOrNullableJsonb + SingleValue,
2805 Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2806 >(
2807 base: E,
2808 path: Arr,
2809 new_value: E,
2810 ) -> Arr::Out;
2811
2812 #[sql_name = "jsonb_insert"]
2867 fn jsonb_insert_with_insert_after<
2868 E: JsonbOrNullableJsonb + SingleValue,
2869 Arr: TextArrayOrNullableTextArray + CombinedNullableValue<E, Jsonb>,
2870 >(
2871 base: E,
2872 path: Arr,
2873 new_value: E,
2874 insert_after: Bool,
2875 ) -> Arr::Out;
2876
2877 #[cfg(feature = "postgres_backend")]
2940 #[sql_name = "json_build_array"]
2941 #[variadic(1)]
2942 fn json_build_array<V: SingleValue>(value: V) -> Json;
2943
2944 #[cfg(feature = "postgres_backend")]
3007 #[sql_name = "jsonb_build_array"]
3008 #[variadic(1)]
3009 fn jsonb_build_array<V: SingleValue>(value: V) -> Jsonb;
3010 #[cfg(feature = "postgres_backend")]
3064 #[sql_name = "json_extract_path"]
3065 #[variadic(last_arguments = 1, skip_zero_argument_variant = true)]
3066 fn json_extract_path<J: JsonOrNullableJson + SingleValue, T: SingleValue>(
3067 json: J,
3068 text: T,
3069 ) -> Nullable<Json>;
3070
3071 #[cfg(feature = "postgres_backend")]
3125 #[sql_name = "jsonb_extract_path"]
3126 #[variadic(last_arguments = 1, skip_zero_argument_variant = true)]
3127 fn jsonb_extract_path<J: JsonbOrNullableJsonb + SingleValue, T: SingleValue>(
3128 json: J,
3129 text: T,
3130 ) -> Nullable<Jsonb>;
3131
3132 #[cfg(feature = "postgres_backend")]
3185 #[sql_name = "json_extract_path_text"]
3186 #[variadic(last_arguments = 1, skip_zero_argument_variant = true)]
3187 fn json_extract_path_text<
3188 J: JsonOrNullableJson + SingleValue,
3189 T: SingleValue + TextOrNullableText,
3190 >(
3191 json: J,
3192 text: T,
3193 ) -> Nullable<Text>;
3194
3195 #[cfg(feature = "postgres_backend")]
3248 #[sql_name = "jsonb_extract_path_text"]
3249 #[variadic(last_arguments = 1, skip_zero_argument_variant = true)]
3250 fn jsonb_extract_path_text<
3251 J: JsonbOrNullableJsonb + SingleValue,
3252 T: SingleValue + TextOrNullableText,
3253 >(
3254 json: J,
3255 text: T,
3256 ) -> Nullable<Text>;
3257}
3258
3259pub(super) mod return_type_helpers_reexported {
3260 #[allow(unused_imports)]
3261 #[doc(inline)]
3262 pub use super::return_type_helpers::*;
3263}