1#[cfg(doc)]
3use crate::expression::functions::aggregate_expressions::AggregateExpressionMethods;
4use crate::expression::functions::declare_sql_function;
5use crate::sql_types::*;
6use crate::sqlite::expression::expression_methods::BinaryOrNullableBinary;
7use crate::sqlite::expression::expression_methods::JsonOrNullableJson;
8use crate::sqlite::expression::expression_methods::JsonOrNullableJsonOrJsonbOrNullableJsonb;
9use crate::sqlite::expression::expression_methods::MaybeNullableValue;
10use crate::sqlite::expression::expression_methods::NotBlob;
11use crate::sqlite::expression::expression_methods::TextOrNullableText;
12use crate::sqlite::expression::expression_methods::TextOrNullableTextOrBinaryOrNullableBinary;
13use crate::sqlite::expression::functions::helper::CombinedNullableValue;
14
15#[cfg(feature = "sqlite")]
16#[doc =
" Verifies that its argument is a valid JSON string or JSONB blob and returns a minified"]
#[doc =
" version of that JSON string with all unnecessary whitespace removed."]
#[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;"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Text, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc =
" let result = diesel::select(json::<Text, _>(r#\"{\"a\": \"b\", \"c\": 1}\"#))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!({\"a\":\"b\",\"c\":1}), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json::<Text, _>(r#\"{ \"this\" : \"is\", \"a\": [ \"test\" ] }\"#))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!({\"a\":[\"test\"],\"this\":\"is\"}), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json::<Nullable<Text>, _>(None::<&str>))"]
#[doc = " .get_result::<Option<Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json<E: TextOrNullableText + MaybeNullableValue<Json>, e>(e: e)
-> json<E, e> where e: diesel::expression::AsExpression<E> {
json_utils::json { e: e.as_expression(), E: ::std::marker::PhantomData }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json()`](fn@json)"]
pub type json<E, e> =
json_utils::json<E,
<e as diesel::expression::AsExpression<E>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_return_type {
#[doc = "Return type of the [`json()`](fn@super::json) SQL function."]
pub type json<e> =
super::json<<e as diesel::expression::Expression>::SqlType, e>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod 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 json<E, e> {
pub(in super) e: e,
pub(in super) E: ::std::marker::PhantomData<E>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<E, e, __Rhs> ::std::ops::Add<__Rhs> for json<E, e> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Add,
<<Self as Expression>::SqlType as Add>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as
Add>::Rhs> {
type Output = ops::Add<Self, __Rhs::Expression>;
fn add(self, rhs: __Rhs) -> Self::Output {
ops::Add::new(self, rhs.as_expression())
}
}
impl<E, e, __Rhs> ::std::ops::Sub<__Rhs> for json<E, e> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Sub,
<<Self as Expression>::SqlType as Sub>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as
Sub>::Rhs> {
type Output = ops::Sub<Self, __Rhs::Expression>;
fn sub(self, rhs: __Rhs) -> Self::Output {
ops::Sub::new(self, rhs.as_expression())
}
}
impl<E, e, __Rhs> ::std::ops::Mul<__Rhs> for json<E, e> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Mul,
<<Self as Expression>::SqlType as Mul>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as
Mul>::Rhs> {
type Output = ops::Mul<Self, __Rhs::Expression>;
fn mul(self, rhs: __Rhs) -> Self::Output {
ops::Mul::new(self, rhs.as_expression())
}
}
impl<E, e, __Rhs> ::std::ops::Div<__Rhs> for 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
json<E, e> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "json", "e",
&self.e, "E", &&self.E)
}
}
#[automatically_derived]
impl<E: ::core::clone::Clone, e: ::core::clone::Clone>
::core::clone::Clone for json<E, e> {
#[inline]
fn clone(&self) -> json<E, e> {
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 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 json<E, e> {
type QueryId =
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 [`json()`](fn@json)"]
pub type HelperType<E, e> = json<E, <e as AsExpression<E>>::Expression>;
impl<E: TextOrNullableText + MaybeNullableValue<Json>, e> Expression for
json<E, e> where (e): Expression {
type SqlType = E::Out;
}
impl<E: TextOrNullableText + MaybeNullableValue<Json>, e,
__DieselInternal> SelectableExpression<__DieselInternal> for
json<E, e> where e: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<E: TextOrNullableText + MaybeNullableValue<Json>, e,
__DieselInternal> AppearsOnTable<__DieselInternal> for json<E, e>
where e: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<E: TextOrNullableText + MaybeNullableValue<Json>, e,
__DieselInternal> FunctionFragment<__DieselInternal> for json<E, e>
where __DieselInternal: diesel::backend::Backend,
e: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "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: TextOrNullableText + MaybeNullableValue<Json>, e>
QueryFragment<crate::sqlite::Sqlite> for json<E, e> where
e: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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: TextOrNullableText + MaybeNullableValue<Json>, e,
__DieselInternal> ValidGrouping<__DieselInternal> for json<E, e> where
__Derived<e>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<e> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The jsonb(X) function returns the binary JSONB representation of the JSON provided as argument X."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.45 or newer"]
#[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::{sql, jsonb};"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Text, Binary, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 45, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb::<Binary, _>(br#\"{\"a\": \"b\", \"c\": 1}\"#))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!({\"a\": \"b\", \"c\": 1}), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb::<Binary, _>(br#\"{\"this\":\"is\",\"a\":[\"test\"]}\"#))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(json!({\"this\":\"is\",\"a\":[\"test\"]}), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb::<Nullable<Binary>, _>(None::<Vec<u8>>))"]
#[doc = " .get_result::<Option<Value>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb<E: BinaryOrNullableBinary + MaybeNullableValue<Jsonb>, e>(e: e)
-> jsonb<E, e> where e: diesel::expression::AsExpression<E> {
jsonb_utils::jsonb { e: e.as_expression(), E: ::std::marker::PhantomData }
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb()`](fn@jsonb)"]
pub type jsonb<E, e> =
jsonb_utils::jsonb<E,
<e as diesel::expression::AsExpression<E>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_return_type {
#[doc = "Return type of the [`jsonb()`](fn@super::jsonb) SQL function."]
pub type jsonb<e> =
super::jsonb<<e as diesel::expression::Expression>::SqlType, e>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod 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 jsonb<E, e> {
pub(in super) e: e,
pub(in super) E: ::std::marker::PhantomData<E>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<E, e, __Rhs> ::std::ops::Add<__Rhs> for jsonb<E, e> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Add,
<<Self as Expression>::SqlType as Add>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as
Add>::Rhs> {
type Output = ops::Add<Self, __Rhs::Expression>;
fn add(self, rhs: __Rhs) -> Self::Output {
ops::Add::new(self, rhs.as_expression())
}
}
impl<E, e, __Rhs> ::std::ops::Sub<__Rhs> for jsonb<E, e> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Sub,
<<Self as Expression>::SqlType as Sub>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as
Sub>::Rhs> {
type Output = ops::Sub<Self, __Rhs::Expression>;
fn sub(self, rhs: __Rhs) -> Self::Output {
ops::Sub::new(self, rhs.as_expression())
}
}
impl<E, e, __Rhs> ::std::ops::Mul<__Rhs> for jsonb<E, e> where
Self: Expression, Self: Expression,
<Self as Expression>::SqlType: Mul,
<<Self as Expression>::SqlType as Mul>::Rhs: SqlType +
SingleValue,
__Rhs: AsExpression<<<Self as Expression>::SqlType as
Mul>::Rhs> {
type Output = ops::Mul<Self, __Rhs::Expression>;
fn mul(self, rhs: __Rhs) -> Self::Output {
ops::Mul::new(self, rhs.as_expression())
}
}
impl<E, e, __Rhs> ::std::ops::Div<__Rhs> for 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
jsonb<E, e> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "jsonb",
"e", &self.e, "E", &&self.E)
}
}
#[automatically_derived]
impl<E: ::core::clone::Clone, e: ::core::clone::Clone>
::core::clone::Clone for jsonb<E, e> {
#[inline]
fn clone(&self) -> jsonb<E, e> {
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 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 jsonb<E, e> {
type QueryId =
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 [`jsonb()`](fn@jsonb)"]
pub type HelperType<E, e> = jsonb<E, <e as AsExpression<E>>::Expression>;
impl<E: BinaryOrNullableBinary + MaybeNullableValue<Jsonb>, e> Expression
for jsonb<E, e> where (e): Expression {
type SqlType = E::Out;
}
impl<E: BinaryOrNullableBinary + MaybeNullableValue<Jsonb>, e,
__DieselInternal> SelectableExpression<__DieselInternal> for
jsonb<E, e> where e: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<E: BinaryOrNullableBinary + MaybeNullableValue<Jsonb>, e,
__DieselInternal> AppearsOnTable<__DieselInternal> for jsonb<E, e>
where e: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<E: BinaryOrNullableBinary + MaybeNullableValue<Jsonb>, e,
__DieselInternal> FunctionFragment<__DieselInternal> for jsonb<E, e>
where __DieselInternal: diesel::backend::Backend,
e: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "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: BinaryOrNullableBinary + MaybeNullableValue<Jsonb>, e>
QueryFragment<crate::sqlite::Sqlite> for jsonb<E, e> where
e: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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: BinaryOrNullableBinary + MaybeNullableValue<Jsonb>, e,
__DieselInternal> ValidGrouping<__DieselInternal> for jsonb<E, e>
where __Derived<e>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<e> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The json_array_length(X) function returns the number of elements in the JSON array X,"]
#[doc = " or 0 if X is some kind of JSON value other than an array."]
#[doc =
" Errors are thrown if either X is not well-formed JSON or if P is not a well-formed path."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.46 or newer"]
#[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::{sql, json_array_length};"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Json, Jsonb, Text, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 46, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length::<Json, _>(json!([1,2,3,4])))"]
#[doc = " .get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(4, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length::<Json, _>(json!({\"one\":[1,2,3]})))"]
#[doc = " .get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(0, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length::<Nullable<Json>, _>(None::<Value>))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length::<Jsonb, _>(json!([1,2,3,4])))"]
#[doc = " .get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(4, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length::<Jsonb, _>(json!({\"one\":[1,2,3]})))"]
#[doc = " .get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(0, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length::<Nullable<Jsonb>, _>(None::<Value>))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_array_length<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Integer>, j>(j: j) -> json_array_length<J, j> where
j: diesel::expression::AsExpression<J> {
json_array_length_utils::json_array_length {
j: j.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_array_length()`](fn@json_array_length)"]
pub type json_array_length<J, j> =
json_array_length_utils::json_array_length<J,
<j as diesel::expression::AsExpression<J>>::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<j> =
super::json_array_length<<j as
diesel::expression::Expression>::SqlType, j>;
}
#[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<J, j> {
pub(in super) j: j,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, j, __Rhs> ::std::ops::Add<__Rhs> for
json_array_length<J, j> 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, j, __Rhs> ::std::ops::Sub<__Rhs> for
json_array_length<J, j> 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, j, __Rhs> ::std::ops::Mul<__Rhs> for
json_array_length<J, j> 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, j, __Rhs> ::std::ops::Div<__Rhs> for
json_array_length<J, j> 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, j: ::core::fmt::Debug> ::core::fmt::Debug for
json_array_length<J, j> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"json_array_length", "j", &self.j, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, j: ::core::clone::Clone>
::core::clone::Clone for json_array_length<J, j> {
#[inline]
fn clone(&self) -> json_array_length<J, j> {
json_array_length {
j: ::core::clone::Clone::clone(&self.j),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, j: ::core::marker::Copy>
::core::marker::Copy for json_array_length<J, j> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
j: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for json_array_length<J, j> {
type QueryId =
json_array_length<<J as
diesel::query_builder::QueryId>::QueryId,
<j as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<j as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<j as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_array_length()`](fn@json_array_length)"]
pub type HelperType<J, j> =
json_array_length<J, <j as AsExpression<J>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Integer>, j> Expression for json_array_length<J, j>
where (j): Expression {
type SqlType = J::Out;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Integer>, j, __DieselInternal>
SelectableExpression<__DieselInternal> for json_array_length<J, j>
where j: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Integer>, j, __DieselInternal>
AppearsOnTable<__DieselInternal> for json_array_length<J, j> where
j: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Integer>, j, __DieselInternal>
FunctionFragment<__DieselInternal> for json_array_length<J, j> where
__DieselInternal: diesel::backend::Backend,
j: 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.j.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.j.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Integer>, j> QueryFragment<crate::sqlite::Sqlite>
for json_array_length<J, j> where
j: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<j>(j);
const _: () =
{
use diesel;
impl<j, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<j> where
j: diesel::expression::ValidGrouping<__GroupByClause> {
type IsAggregate =
<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Integer>, j, __DieselInternal>
ValidGrouping<__DieselInternal> for json_array_length<J, j> where
__Derived<j>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<j> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The json_array_length(X) function returns the number of elements in the JSON array X,"]
#[doc = " or 0 if X is some kind of JSON value other than an array."]
#[doc =
" The json_array_length(X,P) locates the array at path P within X and returns the length of that array,"]
#[doc = " or 0 if path P locates an element in X that is not a JSON array,"]
#[doc = " and NULL if path P does not locate any element of X."]
#[doc =
" Errors are thrown if either X is not well-formed JSON or if P is not a well-formed path."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.46 or newer"]
#[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::{sql, json_array_length_with_path};"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Json, Jsonb, Text, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 46, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length_with_path::<Json, _, _>(json!([1,2,3,4]), \"$\"))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(4), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length_with_path::<Json, _, _>(json!([1,2,3,4]), \"$[2]\"))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(0), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length_with_path::<Json, _, _>(json!({\"one\":[1,2,3]}), \"$.one\"))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(3), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length_with_path::<Nullable<Json>, _, _>(json!({\"one\":[1,2,3]}), \"$.two\"))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length_with_path::<Jsonb, _, _>(json!([1,2,3,4]), \"$\"))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(4), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length_with_path::<Jsonb, _, _>(json!([1,2,3,4]), \"$[2]\"))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(0), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length_with_path::<Jsonb, _, _>(json!({\"one\":[1,2,3]}), \"$.one\"))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(3), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_length_with_path::<Nullable<Jsonb>, _, _>(json!({\"one\":[1,2,3]}), \"$.two\"))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_array_length_with_path<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
SingleValue, j, path>(j: j, path: path)
-> json_array_length_with_path<J, j, path> where
j: diesel::expression::AsExpression<J>,
path: diesel::expression::AsExpression<Text> {
json_array_length_with_path_utils::json_array_length_with_path {
j: j.as_expression(),
path: path.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_array_length_with_path()`](fn@json_array_length_with_path)"]
pub type json_array_length_with_path<J, j, path> =
json_array_length_with_path_utils::json_array_length_with_path<J,
<j as diesel::expression::AsExpression<J>>::Expression,
<path as diesel::expression::AsExpression<Text>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_array_length_with_path_return_type {
#[doc =
"Return type of the [`json_array_length_with_path()`](fn@super::json_array_length_with_path) SQL function."]
pub type json_array_length_with_path<j, path> =
super::json_array_length_with_path<<j as
diesel::expression::Expression>::SqlType, j, path>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_array_length_with_path_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_with_path<J, j, path> {
pub(in super) j: j,
pub(in super) path: path,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, j, path, __Rhs> ::std::ops::Add<__Rhs> for
json_array_length_with_path<J, j, path> 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, j, path, __Rhs> ::std::ops::Sub<__Rhs> for
json_array_length_with_path<J, j, path> 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, j, path, __Rhs> ::std::ops::Mul<__Rhs> for
json_array_length_with_path<J, j, path> 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, j, path, __Rhs> ::std::ops::Div<__Rhs> for
json_array_length_with_path<J, j, path> 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, j: ::core::fmt::Debug,
path: ::core::fmt::Debug> ::core::fmt::Debug for
json_array_length_with_path<J, j, path> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"json_array_length_with_path", "j", &self.j, "path",
&self.path, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, j: ::core::clone::Clone,
path: ::core::clone::Clone> ::core::clone::Clone for
json_array_length_with_path<J, j, path> {
#[inline]
fn clone(&self) -> json_array_length_with_path<J, j, path> {
json_array_length_with_path {
j: ::core::clone::Clone::clone(&self.j),
path: ::core::clone::Clone::clone(&self.path),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, j: ::core::marker::Copy,
path: ::core::marker::Copy> ::core::marker::Copy for
json_array_length_with_path<J, j, path> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
j: diesel::query_builder::QueryId,
path: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_array_length_with_path<J, j, path> {
type QueryId =
json_array_length_with_path<<J as
diesel::query_builder::QueryId>::QueryId,
<j as diesel::query_builder::QueryId>::QueryId,
<path as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<j as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<path as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<j as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<path as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
|| false;
}
};
#[doc =
"The return type of [`json_array_length_with_path()`](fn@json_array_length_with_path)"]
pub type HelperType<J, j, path> =
json_array_length_with_path<J, <j as AsExpression<J>>::Expression,
<path as AsExpression<Text>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path>
Expression for json_array_length_with_path<J, j, path> where
(j, path): Expression {
type SqlType = Nullable<Integer>;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path,
__DieselInternal> SelectableExpression<__DieselInternal> for
json_array_length_with_path<J, j, path> where
j: SelectableExpression<__DieselInternal>,
path: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path,
__DieselInternal> AppearsOnTable<__DieselInternal> for
json_array_length_with_path<J, j, path> where
j: AppearsOnTable<__DieselInternal>,
path: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path,
__DieselInternal> FunctionFragment<__DieselInternal> for
json_array_length_with_path<J, j, path> where
__DieselInternal: diesel::backend::Backend,
j: QueryFragment<__DieselInternal>,
path: 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.j.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.j.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;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path>
QueryFragment<crate::sqlite::Sqlite> for
json_array_length_with_path<J, j, path> where
j: QueryFragment<crate::sqlite::Sqlite>,
path: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<j, path>(j, path);
const _: () =
{
use diesel;
impl<j, path, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<j, path> where
j: diesel::expression::ValidGrouping<__GroupByClause>,
path: diesel::expression::ValidGrouping<__GroupByClause>,
<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<path as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path,
__DieselInternal> ValidGrouping<__DieselInternal> for
json_array_length_with_path<J, j, path> where
__Derived<j, path>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<j, path> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The json_error_position(X) function returns 0 if the input X is a well-formed JSON or JSON5 string."]
#[doc =
" If the input X contains one or more syntax errors, then this function returns the character position of the first syntax error."]
#[doc = " The left-most character is position 1."]
#[doc = ""]
#[doc =
" If the input X is a BLOB, then this routine returns 0 if X is a well-formed JSONB blob. If the return value is positive,"]
#[doc =
" then it represents the approximate 1-based position in the BLOB of the first detected error."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.46 or newer"]
#[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::{sql, json_error_position};"]
#[doc = " # use diesel::sql_types::{Binary, Text, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 46, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_error_position::<Text, _>(r#\"{\"a\": \"b\", \"c\": 1}\"#))"]
#[doc = " .get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(0, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_error_position::<Text, _>(r#\"{\"a\": b\", \"c\": 1}\"#))"]
#[doc = " .get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(7, result);"]
#[doc = ""]
#[doc = " let json5 = r#\""]
#[doc = " {"]
#[doc = " // A traditional message."]
#[doc = " message: \'hello world\',"]
#[doc = ""]
#[doc = " // A number for some reason."]
#[doc = " n: 42,"]
#[doc = " }"]
#[doc = " \"#;"]
#[doc = " let result ="]
#[doc =
" diesel::select(json_error_position::<Text, _>(json5)).get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(0, result);"]
#[doc = ""]
#[doc = " let json5_with_error = r#\""]
#[doc = " {"]
#[doc = " // A traditional message."]
#[doc = " message: hello world\',"]
#[doc = ""]
#[doc = " // A number for some reason."]
#[doc = " n: 42,"]
#[doc = " }"]
#[doc = " \"#;"]
#[doc =
" let result = diesel::select(json_error_position::<Text, _>(json5_with_error))"]
#[doc = " .get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(59, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_error_position::<Nullable<Text>, _>(None::<&str>))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_error_position::<Binary, _>(br#\"{\"a\": \"b\", \"c\": 1}\"#))"]
#[doc = " .get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(0, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_error_position::<Binary, _>(br#\"{\"a\": b\", \"c\": 1}\"#))"]
#[doc = " .get_result::<i32>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(7, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_error_position::<Nullable<Binary>, _>(None::<Vec<u8>>))"]
#[doc = " .get_result::<Option<i32>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_error_position<X: TextOrNullableTextOrBinaryOrNullableBinary +
MaybeNullableValue<Integer>, x>(x: x) -> json_error_position<X, x> where
x: diesel::expression::AsExpression<X> {
json_error_position_utils::json_error_position {
x: x.as_expression(),
X: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_error_position()`](fn@json_error_position)"]
pub type json_error_position<X, x> =
json_error_position_utils::json_error_position<X,
<x as diesel::expression::AsExpression<X>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_error_position_return_type {
#[doc =
"Return type of the [`json_error_position()`](fn@super::json_error_position) SQL function."]
pub type json_error_position<x> =
super::json_error_position<<x as
diesel::expression::Expression>::SqlType, x>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_error_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 json_error_position<X, x> {
pub(in super) x: x,
pub(in super) X: ::std::marker::PhantomData<X>,
}
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<X, x, __Rhs> ::std::ops::Add<__Rhs> for
json_error_position<X, x> 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<X, x, __Rhs> ::std::ops::Sub<__Rhs> for
json_error_position<X, x> 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<X, x, __Rhs> ::std::ops::Mul<__Rhs> for
json_error_position<X, x> 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<X, x, __Rhs> ::std::ops::Div<__Rhs> for
json_error_position<X, x> 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<X: ::core::fmt::Debug, x: ::core::fmt::Debug> ::core::fmt::Debug for
json_error_position<X, x> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"json_error_position", "x", &self.x, "X", &&self.X)
}
}
#[automatically_derived]
impl<X: ::core::clone::Clone, x: ::core::clone::Clone>
::core::clone::Clone for json_error_position<X, x> {
#[inline]
fn clone(&self) -> json_error_position<X, x> {
json_error_position {
x: ::core::clone::Clone::clone(&self.x),
X: ::core::clone::Clone::clone(&self.X),
}
}
}
#[automatically_derived]
impl<X: ::core::marker::Copy, x: ::core::marker::Copy>
::core::marker::Copy for json_error_position<X, x> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<X: diesel::query_builder::QueryId,
x: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for json_error_position<X, x> {
type QueryId =
json_error_position<<X as
diesel::query_builder::QueryId>::QueryId,
<x as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<X as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<x as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<X as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<x as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_error_position()`](fn@json_error_position)"]
pub type HelperType<X, x> =
json_error_position<X, <x as AsExpression<X>>::Expression>;
impl<X: TextOrNullableTextOrBinaryOrNullableBinary +
MaybeNullableValue<Integer>, x> Expression for
json_error_position<X, x> where (x): Expression {
type SqlType = X::Out;
}
impl<X: TextOrNullableTextOrBinaryOrNullableBinary +
MaybeNullableValue<Integer>, x, __DieselInternal>
SelectableExpression<__DieselInternal> for json_error_position<X, x>
where x: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<X: TextOrNullableTextOrBinaryOrNullableBinary +
MaybeNullableValue<Integer>, x, __DieselInternal>
AppearsOnTable<__DieselInternal> for json_error_position<X, x> where
x: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<X: TextOrNullableTextOrBinaryOrNullableBinary +
MaybeNullableValue<Integer>, x, __DieselInternal>
FunctionFragment<__DieselInternal> for json_error_position<X, x> where
__DieselInternal: diesel::backend::Backend,
x: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_error_position";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.x.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.x.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<X: TextOrNullableTextOrBinaryOrNullableBinary +
MaybeNullableValue<Integer>, x> QueryFragment<crate::sqlite::Sqlite>
for json_error_position<X, x> where
x: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<x>(x);
const _: () =
{
use diesel;
impl<x, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<x> where
x: diesel::expression::ValidGrouping<__GroupByClause> {
type IsAggregate =
<x as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
}
};
impl<X: TextOrNullableTextOrBinaryOrNullableBinary +
MaybeNullableValue<Integer>, x, __DieselInternal>
ValidGrouping<__DieselInternal> for json_error_position<X, x> where
__Derived<x>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<x> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc = " Converts the given json value to pretty-printed, indented text"]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.46 or newer"]
#[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::{sql, json_pretty};"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Text, Json, Jsonb, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 46, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty::<Json, _>(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(json_pretty::<Json, _>(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(json_pretty::<Json, _>(json!(\"abc\")))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"\"abc\"\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_pretty::<Json, _>(json!(22)))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"22\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_pretty::<Json, _>(json!(false)))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"false\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_pretty::<Json, _>(json!(null)))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"null\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_pretty::<Json, _>(json!({})))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"{}\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty::<Nullable<Json>, _>(None::<Value>))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_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(json_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(json_pretty::<Jsonb, _>(json!(\"abc\")))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"\"abc\"\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_pretty::<Jsonb, _>(json!(22)))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"22\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_pretty::<Jsonb, _>(json!(false)))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"false\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_pretty::<Jsonb, _>(json!(null)))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"null\"#, result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_pretty::<Jsonb, _>(json!({})))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"{}\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_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 json_pretty<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j>(j: j) -> json_pretty<J, j> where
j: diesel::expression::AsExpression<J> {
json_pretty_utils::json_pretty {
j: j.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_pretty()`](fn@json_pretty)"]
pub type json_pretty<J, j> =
json_pretty_utils::json_pretty<J,
<j as diesel::expression::AsExpression<J>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_pretty_return_type {
#[doc =
"Return type of the [`json_pretty()`](fn@super::json_pretty) SQL function."]
pub type json_pretty<j> =
super::json_pretty<<j as diesel::expression::Expression>::SqlType, j>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_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 json_pretty<J, j> {
pub(in super) j: j,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, j, __Rhs> ::std::ops::Add<__Rhs> for json_pretty<J, j>
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, j, __Rhs> ::std::ops::Sub<__Rhs> for json_pretty<J, j>
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, j, __Rhs> ::std::ops::Mul<__Rhs> for json_pretty<J, j>
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, j, __Rhs> ::std::ops::Div<__Rhs> for json_pretty<J, j>
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, j: ::core::fmt::Debug> ::core::fmt::Debug for
json_pretty<J, j> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"json_pretty", "j", &self.j, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, j: ::core::clone::Clone>
::core::clone::Clone for json_pretty<J, j> {
#[inline]
fn clone(&self) -> json_pretty<J, j> {
json_pretty {
j: ::core::clone::Clone::clone(&self.j),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, j: ::core::marker::Copy>
::core::marker::Copy for json_pretty<J, j> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
j: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for json_pretty<J, j> {
type QueryId =
json_pretty<<J as diesel::query_builder::QueryId>::QueryId,
<j as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<j as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<j as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`json_pretty()`](fn@json_pretty)"]
pub type HelperType<J, j> =
json_pretty<J, <j as AsExpression<J>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j> Expression for json_pretty<J, j> where
(j): Expression {
type SqlType = J::Out;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, __DieselInternal>
SelectableExpression<__DieselInternal> for json_pretty<J, j> where
j: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, __DieselInternal>
AppearsOnTable<__DieselInternal> for json_pretty<J, j> where
j: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, __DieselInternal>
FunctionFragment<__DieselInternal> for json_pretty<J, j> where
__DieselInternal: diesel::backend::Backend,
j: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_pretty";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.j.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.j.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j> QueryFragment<crate::sqlite::Sqlite> for
json_pretty<J, j> where j: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<j>(j);
const _: () =
{
use diesel;
impl<j, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<j> where
j: diesel::expression::ValidGrouping<__GroupByClause> {
type IsAggregate =
<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, __DieselInternal>
ValidGrouping<__DieselInternal> for json_pretty<J, j> where
__Derived<j>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<j> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc = " Converts the given json value to pretty-printed, indented text"]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.46 or newer"]
#[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::{sql, json_pretty_with_indentation};"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Text, Json, Jsonb, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 46, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Json, _, _>(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(json_pretty_with_indentation::<Json, _, _>(json!([{\"f1\":1,\"f2\":null},2,null,3]), None::<&str>))"]
#[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(json_pretty_with_indentation::<Json, _, _>(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(json_pretty_with_indentation::<Json, _, _>(json!(\"abc\"), \" \"))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"\"abc\"\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Json, _, _>(json!(22), \" \"))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"22\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Json, _, _>(json!(false), None::<&str>))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"false\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Json, _, _>(json!(null), None::<&str>))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"null\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Json, _, _>(json!({}), \" \"))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"{}\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Nullable<Json>, _, _>(None::<Value>, None::<&str>))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<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(json_pretty_with_indentation::<Jsonb, _, _>(json!([{\"f1\":1,\"f2\":null},2,null,3]), None::<&str>))"]
#[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(json_pretty_with_indentation::<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(json_pretty_with_indentation::<Jsonb, _, _>(json!(\"abc\"), \" \"))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"\"abc\"\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Jsonb, _, _>(json!(22), \" \"))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"22\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Jsonb, _, _>(json!(false), None::<&str>))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"false\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Jsonb, _, _>(json!(null), None::<&str>))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"null\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Jsonb, _, _>(json!({}), \" \"))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(r#\"{}\"#, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_pretty_with_indentation::<Nullable<Jsonb>, _, _>(None::<Value>, None::<&str>))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_pretty_with_indentation<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, indentation>(j: j, indentation: indentation)
-> json_pretty_with_indentation<J, j, indentation> where
j: diesel::expression::AsExpression<J>,
indentation: diesel::expression::AsExpression<Nullable<Text>> {
json_pretty_with_indentation_utils::json_pretty_with_indentation {
j: j.as_expression(),
indentation: indentation.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_pretty_with_indentation()`](fn@json_pretty_with_indentation)"]
pub type json_pretty_with_indentation<J, j, indentation> =
json_pretty_with_indentation_utils::json_pretty_with_indentation<J,
<j as diesel::expression::AsExpression<J>>::Expression,
<indentation as
diesel::expression::AsExpression<Nullable<Text>>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_pretty_with_indentation_return_type {
#[doc =
"Return type of the [`json_pretty_with_indentation()`](fn@super::json_pretty_with_indentation) SQL function."]
pub type json_pretty_with_indentation<j, indentation> =
super::json_pretty_with_indentation<<j as
diesel::expression::Expression>::SqlType, j, indentation>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_pretty_with_indentation_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_pretty_with_indentation<J, j, indentation> {
pub(in super) j: j,
pub(in super) indentation: indentation,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, j, indentation, __Rhs> ::std::ops::Add<__Rhs> for
json_pretty_with_indentation<J, j, indentation> 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, j, indentation, __Rhs> ::std::ops::Sub<__Rhs> for
json_pretty_with_indentation<J, j, indentation> 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, j, indentation, __Rhs> ::std::ops::Mul<__Rhs> for
json_pretty_with_indentation<J, j, indentation> 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, j, indentation, __Rhs> ::std::ops::Div<__Rhs> for
json_pretty_with_indentation<J, j, indentation> 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, j: ::core::fmt::Debug,
indentation: ::core::fmt::Debug> ::core::fmt::Debug for
json_pretty_with_indentation<J, j, indentation> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"json_pretty_with_indentation", "j", &self.j, "indentation",
&self.indentation, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, j: ::core::clone::Clone,
indentation: ::core::clone::Clone> ::core::clone::Clone for
json_pretty_with_indentation<J, j, indentation> {
#[inline]
fn clone(&self) -> json_pretty_with_indentation<J, j, indentation> {
json_pretty_with_indentation {
j: ::core::clone::Clone::clone(&self.j),
indentation: ::core::clone::Clone::clone(&self.indentation),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, j: ::core::marker::Copy,
indentation: ::core::marker::Copy> ::core::marker::Copy for
json_pretty_with_indentation<J, j, indentation> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
j: diesel::query_builder::QueryId,
indentation: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_pretty_with_indentation<J, j, indentation> {
type QueryId =
json_pretty_with_indentation<<J as
diesel::query_builder::QueryId>::QueryId,
<j as diesel::query_builder::QueryId>::QueryId,
<indentation as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<j as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<indentation as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<j as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<indentation as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_pretty_with_indentation()`](fn@json_pretty_with_indentation)"]
pub type HelperType<J, j, indentation> =
json_pretty_with_indentation<J, <j as AsExpression<J>>::Expression,
<indentation as AsExpression<Nullable<Text>>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, indentation> Expression for
json_pretty_with_indentation<J, j, indentation> where
(j, indentation): Expression {
type SqlType = J::Out;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, indentation, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_pretty_with_indentation<J, j, indentation> where
j: SelectableExpression<__DieselInternal>,
indentation: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, indentation, __DieselInternal>
AppearsOnTable<__DieselInternal> for
json_pretty_with_indentation<J, j, indentation> where
j: AppearsOnTable<__DieselInternal>,
indentation: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, indentation, __DieselInternal>
FunctionFragment<__DieselInternal> for
json_pretty_with_indentation<J, j, indentation> where
__DieselInternal: diesel::backend::Backend,
j: QueryFragment<__DieselInternal>,
indentation: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_pretty";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.j.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.j.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.indentation.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.indentation.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, indentation>
QueryFragment<crate::sqlite::Sqlite> for
json_pretty_with_indentation<J, j, indentation> where
j: QueryFragment<crate::sqlite::Sqlite>,
indentation: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<j, indentation>(j, indentation);
const _: () =
{
use diesel;
impl<j, indentation, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<j, indentation> where
j: diesel::expression::ValidGrouping<__GroupByClause>,
indentation: diesel::expression::ValidGrouping<__GroupByClause>,
<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<indentation
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<indentation as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, indentation, __DieselInternal>
ValidGrouping<__DieselInternal> for
json_pretty_with_indentation<J, j, indentation> where
__Derived<j, indentation>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<j, indentation> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Returns `true` if the argument is well-formed JSON, or returns `false` if is not well-formed."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.46 or newer"]
#[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::{sql, json_valid};"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Text, Json, Jsonb, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 46, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_valid::<Json, _>(json!({\"x\":35})))"]
#[doc = " .get_result::<bool>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(true, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_valid::<Nullable<Json>, _>(None::<serde_json::Value>))"]
#[doc = " .get_result::<Option<bool>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_valid<J: JsonOrNullableJson + MaybeNullableValue<Bool>, j>(j: j)
-> json_valid<J, j> where j: diesel::expression::AsExpression<J> {
json_valid_utils::json_valid {
j: j.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_valid()`](fn@json_valid)"]
pub type json_valid<J, j> =
json_valid_utils::json_valid<J,
<j as diesel::expression::AsExpression<J>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_valid_return_type {
#[doc =
"Return type of the [`json_valid()`](fn@super::json_valid) SQL function."]
pub type json_valid<j> =
super::json_valid<<j as diesel::expression::Expression>::SqlType, j>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_valid_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_valid<J, j> {
pub(in super) j: j,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, j, __Rhs> ::std::ops::Add<__Rhs> for json_valid<J, j>
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, j, __Rhs> ::std::ops::Sub<__Rhs> for json_valid<J, j>
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, j, __Rhs> ::std::ops::Mul<__Rhs> for json_valid<J, j>
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, j, __Rhs> ::std::ops::Div<__Rhs> for json_valid<J, j>
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, j: ::core::fmt::Debug> ::core::fmt::Debug for
json_valid<J, j> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"json_valid", "j", &self.j, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, j: ::core::clone::Clone>
::core::clone::Clone for json_valid<J, j> {
#[inline]
fn clone(&self) -> json_valid<J, j> {
json_valid {
j: ::core::clone::Clone::clone(&self.j),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, j: ::core::marker::Copy>
::core::marker::Copy for json_valid<J, j> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
j: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for json_valid<J, j> {
type QueryId =
json_valid<<J as diesel::query_builder::QueryId>::QueryId,
<j as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<j as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<j as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`json_valid()`](fn@json_valid)"]
pub type HelperType<J, j> =
json_valid<J, <j as AsExpression<J>>::Expression>;
impl<J: JsonOrNullableJson + MaybeNullableValue<Bool>, j> Expression for
json_valid<J, j> where (j): Expression {
type SqlType = J::Out;
}
impl<J: JsonOrNullableJson + MaybeNullableValue<Bool>, j,
__DieselInternal> SelectableExpression<__DieselInternal> for
json_valid<J, j> where j: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJson + MaybeNullableValue<Bool>, j,
__DieselInternal> AppearsOnTable<__DieselInternal> for
json_valid<J, j> where j: AppearsOnTable<__DieselInternal>,
Self: Expression {}
impl<J: JsonOrNullableJson + MaybeNullableValue<Bool>, j,
__DieselInternal> FunctionFragment<__DieselInternal> for
json_valid<J, j> where __DieselInternal: diesel::backend::Backend,
j: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_valid";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.j.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.j.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJson + MaybeNullableValue<Bool>, j>
QueryFragment<crate::sqlite::Sqlite> for json_valid<J, j> where
j: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<j>(j);
const _: () =
{
use diesel;
impl<j, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<j> where
j: diesel::expression::ValidGrouping<__GroupByClause> {
type IsAggregate =
<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
}
};
impl<J: JsonOrNullableJson + MaybeNullableValue<Bool>, j,
__DieselInternal> ValidGrouping<__DieselInternal> for json_valid<J, j>
where __Derived<j>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<j> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The json_type(X) function returns the \"type\" of the outermost element of X."]
#[doc =
" The \"type\" returned by json_type() is one of the following SQL text values:"]
#[doc =
" \'null\', \'true\', \'false\', \'integer\', \'real\', \'text\', \'array\', or \'object\'."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[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::{sql, json_type};"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Text, Json, Jsonb, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type::<Json, _>(json!({\"a\": [2, 3.5, true, false, null, \"x\"]})))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"object\", result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type::<Jsonb, _>(json!({\"a\": [2, 3.5, true, false, null, \"x\"]})))"]
#[doc = " .get_result::<String>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(\"object\", result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type::<Nullable<Json>, _>(None::<serde_json::Value>))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_type<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j>(j: j) -> json_type<J, j> where
j: diesel::expression::AsExpression<J> {
json_type_utils::json_type {
j: j.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_type()`](fn@json_type)"]
pub type json_type<J, j> =
json_type_utils::json_type<J,
<j as diesel::expression::AsExpression<J>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_type_return_type {
#[doc =
"Return type of the [`json_type()`](fn@super::json_type) SQL function."]
pub type json_type<j> =
super::json_type<<j as diesel::expression::Expression>::SqlType, j>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_type_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_type<J, j> {
pub(in super) j: j,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, j, __Rhs> ::std::ops::Add<__Rhs> for json_type<J, j> 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, j, __Rhs> ::std::ops::Sub<__Rhs> for json_type<J, j> 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, j, __Rhs> ::std::ops::Mul<__Rhs> for json_type<J, j> 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, j, __Rhs> ::std::ops::Div<__Rhs> for json_type<J, j> 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, j: ::core::fmt::Debug> ::core::fmt::Debug for
json_type<J, j> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "json_type",
"j", &self.j, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, j: ::core::clone::Clone>
::core::clone::Clone for json_type<J, j> {
#[inline]
fn clone(&self) -> json_type<J, j> {
json_type {
j: ::core::clone::Clone::clone(&self.j),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, j: ::core::marker::Copy>
::core::marker::Copy for json_type<J, j> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
j: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for json_type<J, j> {
type QueryId =
json_type<<J as diesel::query_builder::QueryId>::QueryId,
<j as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<j as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<j as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`json_type()`](fn@json_type)"]
pub type HelperType<J, j> =
json_type<J, <j as AsExpression<J>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j> Expression for json_type<J, j> where
(j): Expression {
type SqlType = J::Out;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, __DieselInternal>
SelectableExpression<__DieselInternal> for json_type<J, j> where
j: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, __DieselInternal>
AppearsOnTable<__DieselInternal> for json_type<J, j> where
j: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, __DieselInternal>
FunctionFragment<__DieselInternal> for json_type<J, j> where
__DieselInternal: diesel::backend::Backend,
j: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_type";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.j.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.j.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j> QueryFragment<crate::sqlite::Sqlite> for
json_type<J, j> where j: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<j>(j);
const _: () =
{
use diesel;
impl<j, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<j> where
j: diesel::expression::ValidGrouping<__GroupByClause> {
type IsAggregate =
<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
MaybeNullableValue<Text>, j, __DieselInternal>
ValidGrouping<__DieselInternal> for json_type<J, j> where
__Derived<j>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<j> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The json_type(X,P) function returns the \"type\" of the element in X that is selected by path P."]
#[doc =
" If the path P in json_type(X,P) selects an element that does not exist in X, then this function returns NULL."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[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::{sql, json_type_with_path};"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Text, Json, Jsonb, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = ""]
#[doc =
" let json_value = json!({\"a\": [2, 3.5, true, false, null, \"x\"]});"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type_with_path::<Json, _, _>(json_value.clone(), \"$.a\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(\"array\".to_string()), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type_with_path::<Json, _, _>(json_value.clone(), \"$.a[0]\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(\"integer\".to_string()), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type_with_path::<Json, _, _>(json_value.clone(), \"$.a[1]\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(\"real\".to_string()), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type_with_path::<Json, _, _>(json_value.clone(), \"$.a[2]\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(\"true\".to_string()), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type_with_path::<Json, _, _>(json_value.clone(), \"$.a[6]\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type_with_path::<Jsonb, _, _>(json_value.clone(), \"$.a\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(Some(\"array\".to_string()), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_type_with_path::<Nullable<Json>, _, _>(None::<serde_json::Value>, \"$.a\"))"]
#[doc = " .get_result::<Option<String>>(connection)?;"]
#[doc = ""]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_type_with_path<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
SingleValue, j, path>(j: j, path: path) -> json_type_with_path<J, j, path>
where j: diesel::expression::AsExpression<J>,
path: diesel::expression::AsExpression<Text> {
json_type_with_path_utils::json_type_with_path {
j: j.as_expression(),
path: path.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc =
"The return type of [`json_type_with_path()`](fn@json_type_with_path)"]
pub type json_type_with_path<J, j, path> =
json_type_with_path_utils::json_type_with_path<J,
<j as diesel::expression::AsExpression<J>>::Expression,
<path as diesel::expression::AsExpression<Text>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_type_with_path_return_type {
#[doc =
"Return type of the [`json_type_with_path()`](fn@super::json_type_with_path) SQL function."]
pub type json_type_with_path<j, path> =
super::json_type_with_path<<j as
diesel::expression::Expression>::SqlType, j, path>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_type_with_path_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_type_with_path<J, j, path> {
pub(in super) j: j,
pub(in super) path: path,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, j, path, __Rhs> ::std::ops::Add<__Rhs> for
json_type_with_path<J, j, path> 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, j, path, __Rhs> ::std::ops::Sub<__Rhs> for
json_type_with_path<J, j, path> 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, j, path, __Rhs> ::std::ops::Mul<__Rhs> for
json_type_with_path<J, j, path> 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, j, path, __Rhs> ::std::ops::Div<__Rhs> for
json_type_with_path<J, j, path> 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, j: ::core::fmt::Debug,
path: ::core::fmt::Debug> ::core::fmt::Debug for
json_type_with_path<J, j, path> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"json_type_with_path", "j", &self.j, "path", &self.path, "J",
&&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, j: ::core::clone::Clone,
path: ::core::clone::Clone> ::core::clone::Clone for
json_type_with_path<J, j, path> {
#[inline]
fn clone(&self) -> json_type_with_path<J, j, path> {
json_type_with_path {
j: ::core::clone::Clone::clone(&self.j),
path: ::core::clone::Clone::clone(&self.path),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, j: ::core::marker::Copy,
path: ::core::marker::Copy> ::core::marker::Copy for
json_type_with_path<J, j, path> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
j: diesel::query_builder::QueryId,
path: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_type_with_path<J, j, path> {
type QueryId =
json_type_with_path<<J as
diesel::query_builder::QueryId>::QueryId,
<j as diesel::query_builder::QueryId>::QueryId,
<path as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<j as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<path as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<j as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<path as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
|| false;
}
};
#[doc =
"The return type of [`json_type_with_path()`](fn@json_type_with_path)"]
pub type HelperType<J, j, path> =
json_type_with_path<J, <j as AsExpression<J>>::Expression,
<path as AsExpression<Text>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path>
Expression for json_type_with_path<J, j, path> where
(j, path): Expression {
type SqlType = Nullable<Text>;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path,
__DieselInternal> SelectableExpression<__DieselInternal> for
json_type_with_path<J, j, path> where
j: SelectableExpression<__DieselInternal>,
path: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path,
__DieselInternal> AppearsOnTable<__DieselInternal> for
json_type_with_path<J, j, path> where
j: AppearsOnTable<__DieselInternal>,
path: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path,
__DieselInternal> FunctionFragment<__DieselInternal> for
json_type_with_path<J, j, path> where
__DieselInternal: diesel::backend::Backend,
j: QueryFragment<__DieselInternal>,
path: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_type";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.j.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.j.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;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path>
QueryFragment<crate::sqlite::Sqlite> for
json_type_with_path<J, j, path> where
j: QueryFragment<crate::sqlite::Sqlite>,
path: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<j, path>(j, path);
const _: () =
{
use diesel;
impl<j, path, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<j, path> where
j: diesel::expression::ValidGrouping<__GroupByClause>,
path: diesel::expression::ValidGrouping<__GroupByClause>,
<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<path as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, j, path,
__DieselInternal> ValidGrouping<__DieselInternal> for
json_type_with_path<J, j, path> where
__Derived<j, path>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<j, path> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The json_quote(X) function converts the SQL value X (a number or a string) into its corresponding JSON"]
#[doc =
" representation. If X is a JSON value returned by another JSON function, then this function is a no-op."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[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::{sql, json_quote};"]
#[doc = " # use serde_json::{json, Value};"]
#[doc =
" # use diesel::sql_types::{Text, Json, Integer, Float, Double, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_quote::<Integer, _>(42))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!(42), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_quote::<Text, _>(\"verdant\"))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!(\"verdant\"), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_quote::<Text, _>(\"[1]\"))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!(\"[1]\"), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_quote::<Nullable<Text>, _>(None::<&str>))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!(null), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_quote::<Double, _>(3.14159))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!(3.14159), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_quote::<Json, _>(json!([1])))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = ""]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_quote<J: SqlType + SingleValue, j>(j: j) -> json_quote<J, j> where
j: diesel::expression::AsExpression<J> {
json_quote_utils::json_quote {
j: j.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_quote()`](fn@json_quote)"]
pub type json_quote<J, j> =
json_quote_utils::json_quote<J,
<j as diesel::expression::AsExpression<J>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_quote_return_type {
#[doc =
"Return type of the [`json_quote()`](fn@super::json_quote) SQL function."]
pub type json_quote<j> =
super::json_quote<<j as diesel::expression::Expression>::SqlType, j>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_quote_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_quote<J, j> {
pub(in super) j: j,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, j, __Rhs> ::std::ops::Add<__Rhs> for json_quote<J, j>
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, j, __Rhs> ::std::ops::Sub<__Rhs> for json_quote<J, j>
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, j, __Rhs> ::std::ops::Mul<__Rhs> for json_quote<J, j>
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, j, __Rhs> ::std::ops::Div<__Rhs> for json_quote<J, j>
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, j: ::core::fmt::Debug> ::core::fmt::Debug for
json_quote<J, j> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"json_quote", "j", &self.j, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, j: ::core::clone::Clone>
::core::clone::Clone for json_quote<J, j> {
#[inline]
fn clone(&self) -> json_quote<J, j> {
json_quote {
j: ::core::clone::Clone::clone(&self.j),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, j: ::core::marker::Copy>
::core::marker::Copy for json_quote<J, j> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
j: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for json_quote<J, j> {
type QueryId =
json_quote<<J as diesel::query_builder::QueryId>::QueryId,
<j as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<j as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&& true;
const IS_WINDOW_FUNCTION: bool =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<j as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`json_quote()`](fn@json_quote)"]
pub type HelperType<J, j> =
json_quote<J, <j as AsExpression<J>>::Expression>;
impl<J: SqlType + SingleValue, j> Expression for json_quote<J, j> where
(j): Expression {
type SqlType = Json;
}
impl<J: SqlType + SingleValue, j, __DieselInternal>
SelectableExpression<__DieselInternal> for json_quote<J, j> where
j: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: SqlType + SingleValue, j, __DieselInternal>
AppearsOnTable<__DieselInternal> for json_quote<J, j> where
j: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: SqlType + SingleValue, j, __DieselInternal>
FunctionFragment<__DieselInternal> for json_quote<J, j> where
__DieselInternal: diesel::backend::Backend,
j: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_quote";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.j.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.j.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: SqlType + SingleValue, j> QueryFragment<crate::sqlite::Sqlite> for
json_quote<J, j> where j: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<j>(j);
const _: () =
{
use diesel;
impl<j, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<j> where
j: diesel::expression::ValidGrouping<__GroupByClause> {
type IsAggregate =
<j as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate;
}
};
impl<J: SqlType + SingleValue, j, __DieselInternal>
ValidGrouping<__DieselInternal> for json_quote<J, j> where
__Derived<j>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<j> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The `json_group_array(X)` function is an aggregate SQL function that returns a JSON array comprised of"]
#[doc = " all X values in the aggregation."]
#[doc = ""]
#[doc = " ## Aggregate Function Expression"]
#[doc = ""]
#[doc =
" This function can be used as aggregate expression. See [`AggregateExpressionMethods`] for details."]
#[doc = ""]
#[doc = " # Examples"]
#[doc = ""]
#[doc = " ## Normal function usage"]
#[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::*;"]
#[doc = " # use schema::animals::dsl::*;"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " #"]
#[doc = " let result = animals"]
#[doc = " .select(json_group_array(species))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(result, json!([\"dog\", \"spider\"]));"]
#[doc = ""]
#[doc = " let result = animals"]
#[doc = " .select(json_group_array(legs))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(result, json!([4, 8]));"]
#[doc = ""]
#[doc = " let result = animals"]
#[doc = " .select(json_group_array(name))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(result, json!([\"Jack\", null]));"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[doc = " ## Aggregate function expression"]
#[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::*;"]
#[doc = " # use schema::animals::dsl::*;"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " #"]
#[doc = " let result = animals"]
#[doc =
" .select(json_group_array(species).aggregate_filter(legs.lt(8)))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(result, json!([\"dog\"]));"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[doc = ""]
#[doc = " # See also"]
#[doc =
" - [`jsonb_group_array`](jsonb_group_array()) will return data in JSONB format instead of JSON."]
#[doc =
" - [`json_group_object`](json_group_object()) will return JSON object instead of array."]
#[allow(non_camel_case_types)]
pub fn json_group_array<E: SqlType + SingleValue,
elements>(elements: elements) -> json_group_array<E, elements> where
elements: diesel::expression::AsExpression<E> {
json_group_array_utils::json_group_array {
elements: elements.as_expression(),
E: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_group_array()`](fn@json_group_array)"]
pub type json_group_array<E, elements> =
json_group_array_utils::json_group_array<E,
<elements as diesel::expression::AsExpression<E>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_group_array_return_type {
#[doc =
"Return type of the [`json_group_array()`](fn@super::json_group_array) SQL function."]
pub type json_group_array<elements> =
super::json_group_array<<elements as
diesel::expression::Expression>::SqlType, elements>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_group_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 json_group_array<E, elements> {
pub(in super) elements: elements,
pub(in super) E: ::std::marker::PhantomData<E>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<E, elements, __Rhs> ::std::ops::Add<__Rhs> for
json_group_array<E, elements> 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, elements, __Rhs> ::std::ops::Sub<__Rhs> for
json_group_array<E, elements> 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, elements, __Rhs> ::std::ops::Mul<__Rhs> for
json_group_array<E, elements> 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, elements, __Rhs> ::std::ops::Div<__Rhs> for
json_group_array<E, elements> 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, elements: ::core::fmt::Debug>
::core::fmt::Debug for json_group_array<E, elements> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"json_group_array", "elements", &self.elements, "E", &&self.E)
}
}
#[automatically_derived]
impl<E: ::core::clone::Clone, elements: ::core::clone::Clone>
::core::clone::Clone for json_group_array<E, elements> {
#[inline]
fn clone(&self) -> json_group_array<E, elements> {
json_group_array {
elements: ::core::clone::Clone::clone(&self.elements),
E: ::core::clone::Clone::clone(&self.E),
}
}
}
#[automatically_derived]
impl<E: ::core::marker::Copy, elements: ::core::marker::Copy>
::core::marker::Copy for json_group_array<E, elements> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<E: diesel::query_builder::QueryId,
elements: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_group_array<E, elements> {
type QueryId =
json_group_array<<E as
diesel::query_builder::QueryId>::QueryId,
<elements as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<elements as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<elements as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`json_group_array()`](fn@json_group_array)"]
pub type HelperType<E, elements> =
json_group_array<E, <elements as AsExpression<E>>::Expression>;
impl<E: SqlType + SingleValue, elements> Expression for
json_group_array<E, elements> where (elements): Expression {
type SqlType = Json;
}
impl<E: SqlType + SingleValue, elements, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_group_array<E, elements> where
elements: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<E: SqlType + SingleValue, elements, __DieselInternal>
AppearsOnTable<__DieselInternal> for json_group_array<E, elements>
where elements: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<E: SqlType + SingleValue, elements, __DieselInternal>
FunctionFragment<__DieselInternal> for json_group_array<E, elements>
where __DieselInternal: diesel::backend::Backend,
elements: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_group_array";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.elements.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.elements.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<E: SqlType + SingleValue, elements>
QueryFragment<crate::sqlite::Sqlite> for json_group_array<E, elements>
where elements: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
impl<E: SqlType + SingleValue, elements, __DieselInternal>
ValidGrouping<__DieselInternal> for json_group_array<E, elements> {
type IsAggregate = diesel::expression::is_aggregate::Yes;
}
impl<E: SqlType + SingleValue, elements> IsAggregateFunction for
json_group_array<E, elements> {}
}
#[doc =
" The `jsonb_group_array(X)` function is an aggregate SQL function that returns a JSONB array comprised of"]
#[doc = " all X values in the aggregation."]
#[doc = ""]
#[doc = " ## Aggregate Function Expression"]
#[doc = ""]
#[doc =
" This function can be used as aggregate expression. See [`AggregateExpressionMethods`] for details."]
#[doc = ""]
#[doc = " # Examples"]
#[doc = ""]
#[doc = " ## Normal function usage"]
#[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::*;"]
#[doc = " # use schema::animals::dsl::*;"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " #"]
#[doc = " let result = animals"]
#[doc = " .select(json_group_array(species))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(result, json!([\"dog\", \"spider\"]));"]
#[doc = ""]
#[doc = " let result = animals"]
#[doc = " .select(json_group_array(legs))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(result, json!([4, 8]));"]
#[doc = ""]
#[doc = " let result = animals"]
#[doc = " .select(json_group_array(name))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(result, json!([\"Jack\", null]));"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[doc = ""]
#[doc = " ## Aggregate function expression"]
#[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::*;"]
#[doc = " # use schema::animals::dsl::*;"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " #"]
#[doc = " let result = animals"]
#[doc =
" .select(json_group_array(species).aggregate_filter(legs.lt(8)))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(result, json!([\"dog\"]));"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[doc = ""]
#[doc = " # See also"]
#[doc =
" - [`json_group_array`](json_group_array()) will return data in JSON format instead of JSONB."]
#[doc =
" - [`jsonb_group_object`](jsonb_group_object()) will return JSONB object instead of array."]
#[allow(non_camel_case_types)]
pub fn jsonb_group_array<E: SqlType + SingleValue,
elements>(elements: elements) -> jsonb_group_array<E, elements> where
elements: diesel::expression::AsExpression<E> {
jsonb_group_array_utils::jsonb_group_array {
elements: elements.as_expression(),
E: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_group_array()`](fn@jsonb_group_array)"]
pub type jsonb_group_array<E, elements> =
jsonb_group_array_utils::jsonb_group_array<E,
<elements as diesel::expression::AsExpression<E>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_group_array_return_type {
#[doc =
"Return type of the [`jsonb_group_array()`](fn@super::jsonb_group_array) SQL function."]
pub type jsonb_group_array<elements> =
super::jsonb_group_array<<elements as
diesel::expression::Expression>::SqlType, elements>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_group_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 jsonb_group_array<E, elements> {
pub(in super) elements: elements,
pub(in super) E: ::std::marker::PhantomData<E>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<E, elements, __Rhs> ::std::ops::Add<__Rhs> for
jsonb_group_array<E, elements> 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, elements, __Rhs> ::std::ops::Sub<__Rhs> for
jsonb_group_array<E, elements> 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, elements, __Rhs> ::std::ops::Mul<__Rhs> for
jsonb_group_array<E, elements> 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, elements, __Rhs> ::std::ops::Div<__Rhs> for
jsonb_group_array<E, elements> 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, elements: ::core::fmt::Debug>
::core::fmt::Debug for jsonb_group_array<E, elements> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"jsonb_group_array", "elements", &self.elements, "E",
&&self.E)
}
}
#[automatically_derived]
impl<E: ::core::clone::Clone, elements: ::core::clone::Clone>
::core::clone::Clone for jsonb_group_array<E, elements> {
#[inline]
fn clone(&self) -> jsonb_group_array<E, elements> {
jsonb_group_array {
elements: ::core::clone::Clone::clone(&self.elements),
E: ::core::clone::Clone::clone(&self.E),
}
}
}
#[automatically_derived]
impl<E: ::core::marker::Copy, elements: ::core::marker::Copy>
::core::marker::Copy for jsonb_group_array<E, elements> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<E: diesel::query_builder::QueryId,
elements: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_group_array<E, elements> {
type QueryId =
jsonb_group_array<<E as
diesel::query_builder::QueryId>::QueryId,
<elements as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<E as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<elements as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<E as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<elements as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`jsonb_group_array()`](fn@jsonb_group_array)"]
pub type HelperType<E, elements> =
jsonb_group_array<E, <elements as AsExpression<E>>::Expression>;
impl<E: SqlType + SingleValue, elements> Expression for
jsonb_group_array<E, elements> where (elements): Expression {
type SqlType = Jsonb;
}
impl<E: SqlType + SingleValue, elements, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_group_array<E, elements> where
elements: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<E: SqlType + SingleValue, elements, __DieselInternal>
AppearsOnTable<__DieselInternal> for jsonb_group_array<E, elements>
where elements: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<E: SqlType + SingleValue, elements, __DieselInternal>
FunctionFragment<__DieselInternal> for jsonb_group_array<E, elements>
where __DieselInternal: diesel::backend::Backend,
elements: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_group_array";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.elements.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.elements.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<E: SqlType + SingleValue, elements>
QueryFragment<crate::sqlite::Sqlite> for
jsonb_group_array<E, elements> where
elements: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
impl<E: SqlType + SingleValue, elements, __DieselInternal>
ValidGrouping<__DieselInternal> for jsonb_group_array<E, elements> {
type IsAggregate = diesel::expression::is_aggregate::Yes;
}
impl<E: SqlType + SingleValue, elements> IsAggregateFunction for
jsonb_group_array<E, elements> {}
}
#[doc =
" The json_group_object(NAME,VALUE) function returns a JSON object comprised of all NAME/VALUE pairs in"]
#[doc = " the aggregation."]
#[doc = ""]
#[doc =
" A potential edge case in this function arises when `names` contains duplicate elements."]
#[doc =
" In such case, the result will include all duplicates (e.g., `{\"key\": 1, \"key\": 2, \"key\": 3}`)."]
#[doc =
" Note that any duplicate entries in the resulting JSON will be removed during deserialization."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " ## Aggregate Function Expression"]
#[doc = ""]
#[doc =
" This function can be used as aggregate expression. See [`AggregateExpressionMethods`] for details."]
#[doc = ""]
#[doc = " # Examples"]
#[doc = ""]
#[doc = " ## Normal function usage"]
#[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::*;"]
#[doc = " # use diesel::sql_types::Text;"]
#[doc = " # use serde_json::json;"]
#[doc = " # use schema::animals::dsl::*;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc =
" let result = animals.select(json_group_object(species, name)).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!({\"dog\":\"Jack\",\"spider\":null}), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[doc = ""]
#[doc = " ## Aggregate function expression"]
#[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::*;"]
#[doc = " # use diesel::sql_types::Text;"]
#[doc = " # use serde_json::json;"]
#[doc = " # use schema::animals::dsl::*;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " #"]
#[doc =
" # let version = diesel::select(sql::<Text>(\"sqlite_version();\"))"]
#[doc = " # .get_result::<String>(connection)?;"]
#[doc = " #"]
#[doc =
" # let version_components: Vec<&str> = version.split(\'.\').collect();"]
#[doc = " # let major: u32 = version_components[0].parse().unwrap();"]
#[doc = " # let minor: u32 = version_components[1].parse().unwrap();"]
#[doc = " #"]
#[doc = " # if major < 3 || minor < 38 {"]
#[doc =
" # println!(\"SQLite version is too old, skipping the test.\");"]
#[doc = " # return Ok(());"]
#[doc = " # }"]
#[doc = " #"]
#[doc =
" let result = animals.select(json_group_object(species, name).aggregate_filter(legs.lt(8))).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!({\"dog\":\"Jack\"}), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[doc = ""]
#[doc = " # See also"]
#[doc =
" - [`jsonb_group_object`](jsonb_group_object()) will return data in JSONB format instead of JSON."]
#[doc =
" - [`json_group_array`](json_group_array()) will return JSON array instead of object."]
#[allow(non_camel_case_types)]
pub fn json_group_object<N: SqlType<IsNull = is_nullable::NotNull> +
SingleValue, V: SqlType + SingleValue, names,
values>(names: names, values: values)
-> json_group_object<N, V, names, values> where
names: diesel::expression::AsExpression<N>,
values: diesel::expression::AsExpression<V> {
json_group_object_utils::json_group_object {
names: names.as_expression(),
values: values.as_expression(),
N: ::std::marker::PhantomData,
V: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_group_object()`](fn@json_group_object)"]
pub type json_group_object<N, V, names, values> =
json_group_object_utils::json_group_object<N, V,
<names as diesel::expression::AsExpression<N>>::Expression,
<values as diesel::expression::AsExpression<V>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_group_object_return_type {
#[doc =
"Return type of the [`json_group_object()`](fn@super::json_group_object) SQL function."]
pub type json_group_object<names, values> =
super::json_group_object<<names as
diesel::expression::Expression>::SqlType,
<values as diesel::expression::Expression>::SqlType, names, values>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_group_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_group_object<N, V, names, values> {
pub(in super) names: names,
pub(in super) values: values,
pub(in super) N: ::std::marker::PhantomData<N>,
pub(in super) V: ::std::marker::PhantomData<V>,
}
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<N, V, names, values, __Rhs> ::std::ops::Add<__Rhs> for
json_group_object<N, V, names, 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<N, V, names, values, __Rhs> ::std::ops::Sub<__Rhs> for
json_group_object<N, V, names, 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<N, V, names, values, __Rhs> ::std::ops::Mul<__Rhs> for
json_group_object<N, V, names, 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<N, V, names, values, __Rhs> ::std::ops::Div<__Rhs> for
json_group_object<N, V, names, 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<N: ::core::fmt::Debug, V: ::core::fmt::Debug,
names: ::core::fmt::Debug, values: ::core::fmt::Debug>
::core::fmt::Debug for json_group_object<N, V, names, values> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"json_group_object", "names", &self.names, "values",
&self.values, "N", &self.N, "V", &&self.V)
}
}
#[automatically_derived]
impl<N: ::core::clone::Clone, V: ::core::clone::Clone,
names: ::core::clone::Clone, values: ::core::clone::Clone>
::core::clone::Clone for json_group_object<N, V, names, values> {
#[inline]
fn clone(&self) -> json_group_object<N, V, names, values> {
json_group_object {
names: ::core::clone::Clone::clone(&self.names),
values: ::core::clone::Clone::clone(&self.values),
N: ::core::clone::Clone::clone(&self.N),
V: ::core::clone::Clone::clone(&self.V),
}
}
}
#[automatically_derived]
impl<N: ::core::marker::Copy, V: ::core::marker::Copy,
names: ::core::marker::Copy, values: ::core::marker::Copy>
::core::marker::Copy for json_group_object<N, V, names, values> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<N: diesel::query_builder::QueryId,
V: diesel::query_builder::QueryId,
names: diesel::query_builder::QueryId,
values: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_group_object<N, V, names, values> {
type QueryId =
json_group_object<<N as
diesel::query_builder::QueryId>::QueryId,
<V as diesel::query_builder::QueryId>::QueryId,
<names as diesel::query_builder::QueryId>::QueryId,
<values as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<N as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<V as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<names 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 =
<N as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<V as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<names as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<values as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`json_group_object()`](fn@json_group_object)"]
pub type HelperType<N, V, names, values> =
json_group_object<N, V, <names as AsExpression<N>>::Expression,
<values as AsExpression<V>>::Expression>;
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values> Expression for
json_group_object<N, V, names, values> where
(names, values): Expression {
type SqlType = Json;
}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_group_object<N, V, names, values> where
names: SelectableExpression<__DieselInternal>,
values: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values, __DieselInternal>
AppearsOnTable<__DieselInternal> for
json_group_object<N, V, names, values> where
names: AppearsOnTable<__DieselInternal>,
values: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values, __DieselInternal>
FunctionFragment<__DieselInternal> for
json_group_object<N, V, names, values> where
__DieselInternal: diesel::backend::Backend,
names: QueryFragment<__DieselInternal>,
values: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_group_object";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.names.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.names.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<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values> QueryFragment<crate::sqlite::Sqlite> for
json_group_object<N, V, names, values> where
names: QueryFragment<crate::sqlite::Sqlite>,
values: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values, __DieselInternal>
ValidGrouping<__DieselInternal> for
json_group_object<N, V, names, values> {
type IsAggregate = diesel::expression::is_aggregate::Yes;
}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values> IsAggregateFunction for
json_group_object<N, V, names, values> {}
}
#[doc =
" The jsonb_group_object(NAME,VALUE) function returns a JSONB object comprised of all NAME/VALUE pairs in"]
#[doc = " the aggregation."]
#[doc = ""]
#[doc =
" A potential edge case in this function arises when `names` contains duplicate elements."]
#[doc =
" In such case, the result will include all duplicates (e.g., `{\"key\": 1, \"key\": 2, \"key\": 3}`)."]
#[doc =
" Note that any duplicate entries in the resulting JSONB will be removed during deserialization."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " ## Aggregate Function Expression"]
#[doc = ""]
#[doc =
" This function can be used as aggregate expression. See [`AggregateExpressionMethods`] for details."]
#[doc = ""]
#[doc = " # Examples"]
#[doc = ""]
#[doc = " ## Normal function usage"]
#[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::*;"]
#[doc = " # use diesel::sql_types::Text;"]
#[doc = " # use serde_json::json;"]
#[doc = " # use schema::animals::dsl::*;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc =
" let result = animals.select(jsonb_group_object(species, name)).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!({\"dog\":\"Jack\",\"spider\":null}), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[doc = ""]
#[doc = " ## Aggregate function expression"]
#[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::*;"]
#[doc = " # use diesel::sql_types::Text;"]
#[doc = " # use serde_json::json;"]
#[doc = " # use schema::animals::dsl::*;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " #"]
#[doc =
" # let version = diesel::select(sql::<Text>(\"sqlite_version();\"))"]
#[doc = " # .get_result::<String>(connection)?;"]
#[doc = " #"]
#[doc =
" # let version_components: Vec<&str> = version.split(\'.\').collect();"]
#[doc = " # let major: u32 = version_components[0].parse().unwrap();"]
#[doc = " # let minor: u32 = version_components[1].parse().unwrap();"]
#[doc = " #"]
#[doc = " # if major < 3 || minor < 38 {"]
#[doc =
" # println!(\"SQLite version is too old, skipping the test.\");"]
#[doc = " # return Ok(());"]
#[doc = " # }"]
#[doc = " #"]
#[doc =
" let result = animals.select(jsonb_group_object(species, name).aggregate_filter(legs.lt(8))).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!({\"dog\":\"Jack\"}), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[doc = ""]
#[doc = " # See also"]
#[doc =
" - [`json_group_object`](jsonb_group_array()) will return data in JSON format instead of JSONB."]
#[doc =
" - [`jsonb_group_array`](jsonb_group_array()) will return JSONB array instead of object."]
#[allow(non_camel_case_types)]
pub fn jsonb_group_object<N: SqlType<IsNull = is_nullable::NotNull> +
SingleValue, V: SqlType + SingleValue, names,
values>(names: names, values: values)
-> jsonb_group_object<N, V, names, values> where
names: diesel::expression::AsExpression<N>,
values: diesel::expression::AsExpression<V> {
jsonb_group_object_utils::jsonb_group_object {
names: names.as_expression(),
values: values.as_expression(),
N: ::std::marker::PhantomData,
V: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_group_object()`](fn@jsonb_group_object)"]
pub type jsonb_group_object<N, V, names, values> =
jsonb_group_object_utils::jsonb_group_object<N, V,
<names as diesel::expression::AsExpression<N>>::Expression,
<values as diesel::expression::AsExpression<V>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_group_object_return_type {
#[doc =
"Return type of the [`jsonb_group_object()`](fn@super::jsonb_group_object) SQL function."]
pub type jsonb_group_object<names, values> =
super::jsonb_group_object<<names as
diesel::expression::Expression>::SqlType,
<values as diesel::expression::Expression>::SqlType, names, values>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_group_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_group_object<N, V, names, values> {
pub(in super) names: names,
pub(in super) values: values,
pub(in super) N: ::std::marker::PhantomData<N>,
pub(in super) V: ::std::marker::PhantomData<V>,
}
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<N, V, names, values, __Rhs> ::std::ops::Add<__Rhs> for
jsonb_group_object<N, V, names, 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<N, V, names, values, __Rhs> ::std::ops::Sub<__Rhs> for
jsonb_group_object<N, V, names, 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<N, V, names, values, __Rhs> ::std::ops::Mul<__Rhs> for
jsonb_group_object<N, V, names, 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<N, V, names, values, __Rhs> ::std::ops::Div<__Rhs> for
jsonb_group_object<N, V, names, 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<N: ::core::fmt::Debug, V: ::core::fmt::Debug,
names: ::core::fmt::Debug, values: ::core::fmt::Debug>
::core::fmt::Debug for jsonb_group_object<N, V, names, values> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"jsonb_group_object", "names", &self.names, "values",
&self.values, "N", &self.N, "V", &&self.V)
}
}
#[automatically_derived]
impl<N: ::core::clone::Clone, V: ::core::clone::Clone,
names: ::core::clone::Clone, values: ::core::clone::Clone>
::core::clone::Clone for jsonb_group_object<N, V, names, values> {
#[inline]
fn clone(&self) -> jsonb_group_object<N, V, names, values> {
jsonb_group_object {
names: ::core::clone::Clone::clone(&self.names),
values: ::core::clone::Clone::clone(&self.values),
N: ::core::clone::Clone::clone(&self.N),
V: ::core::clone::Clone::clone(&self.V),
}
}
}
#[automatically_derived]
impl<N: ::core::marker::Copy, V: ::core::marker::Copy,
names: ::core::marker::Copy, values: ::core::marker::Copy>
::core::marker::Copy for jsonb_group_object<N, V, names, values> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<N: diesel::query_builder::QueryId,
V: diesel::query_builder::QueryId,
names: diesel::query_builder::QueryId,
values: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_group_object<N, V, names, values> {
type QueryId =
jsonb_group_object<<N as
diesel::query_builder::QueryId>::QueryId,
<V as diesel::query_builder::QueryId>::QueryId,
<names as diesel::query_builder::QueryId>::QueryId,
<values as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<N as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<V as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<names 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 =
<N as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<V as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<names as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<values as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc =
"The return type of [`jsonb_group_object()`](fn@jsonb_group_object)"]
pub type HelperType<N, V, names, values> =
jsonb_group_object<N, V, <names as AsExpression<N>>::Expression,
<values as AsExpression<V>>::Expression>;
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values> Expression for
jsonb_group_object<N, V, names, values> where
(names, values): Expression {
type SqlType = Jsonb;
}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_group_object<N, V, names, values> where
names: SelectableExpression<__DieselInternal>,
values: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values, __DieselInternal>
AppearsOnTable<__DieselInternal> for
jsonb_group_object<N, V, names, values> where
names: AppearsOnTable<__DieselInternal>,
values: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values, __DieselInternal>
FunctionFragment<__DieselInternal> for
jsonb_group_object<N, V, names, values> where
__DieselInternal: diesel::backend::Backend,
names: QueryFragment<__DieselInternal>,
values: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_group_object";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.names.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.names.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<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values> QueryFragment<crate::sqlite::Sqlite> for
jsonb_group_object<N, V, names, values> where
names: QueryFragment<crate::sqlite::Sqlite>,
values: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values, __DieselInternal>
ValidGrouping<__DieselInternal> for
jsonb_group_object<N, V, names, values> {
type IsAggregate = diesel::expression::is_aggregate::Yes;
}
impl<N: SqlType<IsNull = is_nullable::NotNull> + SingleValue, V: SqlType +
SingleValue, names, values> IsAggregateFunction for
jsonb_group_object<N, V, names, values> {}
}
#[doc =
" The `json_array()` SQL function accepts zero or more arguments and returns a well-formed JSON array"]
#[doc =
" that is composed from those arguments. Note that arguments of type BLOB will not be accepted by this"]
#[doc = " function."]
#[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_array_0`, `json_array_1`, ... `json_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_array")]
#[doc = ""]
#[doc =
" An argument with SQL type TEXT is normally converted into a quoted JSON string. However, if the"]
#[doc =
" argument is the output from another json function, then it is stored as JSON. This allows calls to"]
#[doc =
" `json_array()` and `json_object()` to be nested. The [`json()`] function can also be used to force"]
#[doc = " strings to be recognized as JSON."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Text, Double};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc =
" let result = diesel::select(json_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_array_0() -> json_array_0 where {
json_array_0_utils::json_array_0 {}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_array_0()`](fn@json_array_0)"]
pub type json_array_0 = json_array_0_utils::json_array_0<>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_array_0_return_type {
#[doc =
"Return type of the [`json_array_0()`](fn@super::json_array_0) SQL function."]
pub type json_array_0 = super::json_array_0<>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_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_array_0 {}
#[automatically_derived]
impl ::core::fmt::Debug for json_array_0 {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "json_array_0")
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for json_array_0 { }
#[automatically_derived]
impl ::core::clone::Clone for json_array_0 {
#[inline]
fn clone(&self) -> json_array_0 { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for json_array_0 { }
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for json_array_0 {
type QueryId = json_array_0<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[doc = "The return type of [`json_array_0()`](fn@json_array_0)"]
pub type HelperType = json_array_0<>;
impl Expression for json_array_0 where {
type SqlType = Json;
}
impl<__DieselInternal> SelectableExpression<__DieselInternal> for
json_array_0 where Self: AppearsOnTable<__DieselInternal> {}
impl<__DieselInternal> AppearsOnTable<__DieselInternal> for json_array_0
where Self: Expression {}
impl<__DieselInternal> FunctionFragment<__DieselInternal> for json_array_0
where __DieselInternal: diesel::backend::Backend {
const FUNCTION_NAME: &'static str = "json_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::sqlite::Sqlite> for json_array_0 where {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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_array_0
where __Derived<>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The `json_array()` SQL function accepts zero or more arguments and returns a well-formed JSON array"]
#[doc =
" that is composed from those arguments. Note that arguments of type BLOB will not be accepted by this"]
#[doc = " function."]
#[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_array_0`, `json_array_1`, ... `json_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_array")]
#[doc = ""]
#[doc =
" An argument with SQL type TEXT is normally converted into a quoted JSON string. However, if the"]
#[doc =
" argument is the output from another json function, then it is stored as JSON. This allows calls to"]
#[doc =
" `json_array()` and `json_object()` to be nested. The [`json()`] function can also be used to force"]
#[doc = " strings to be recognized as JSON."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Text, Double};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc =
" let result = diesel::select(json_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_array_1<V1: NotBlob, value_1>(value_1: value_1)
-> json_array_1<V1, value_1> where
value_1: diesel::expression::AsExpression<V1> {
json_array_1_utils::json_array_1 {
value_1: value_1.as_expression(),
V1: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_array_1()`](fn@json_array_1)"]
pub type json_array_1<V1, value_1> =
json_array_1_utils::json_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_array_1_return_type {
#[doc =
"Return type of the [`json_array_1()`](fn@super::json_array_1) SQL function."]
pub type json_array_1<value_1> =
super::json_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_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_array_1<V1, value_1> {
pub(in super) value_1: value_1,
pub(in super) V1: ::std::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> ::std::ops::Add<__Rhs> for
json_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> ::std::ops::Sub<__Rhs> for
json_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> ::std::ops::Mul<__Rhs> for
json_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> ::std::ops::Div<__Rhs> for
json_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_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_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_array_1<V1, value_1> {
#[inline]
fn clone(&self) -> json_array_1<V1, value_1> {
json_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_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_array_1<V1, value_1> {
type QueryId =
json_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_array_1()`](fn@json_array_1)"]
pub type HelperType<V1, value_1> =
json_array_1<V1, <value_1 as AsExpression<V1>>::Expression>;
impl<V1: NotBlob, value_1> Expression for json_array_1<V1, value_1> where
(value_1): Expression {
type SqlType = Json;
}
impl<V1: NotBlob, value_1, __DieselInternal>
SelectableExpression<__DieselInternal> for json_array_1<V1, value_1>
where value_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<V1: NotBlob, value_1, __DieselInternal>
AppearsOnTable<__DieselInternal> for json_array_1<V1, value_1> where
value_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<V1: NotBlob, value_1, __DieselInternal>
FunctionFragment<__DieselInternal> for json_array_1<V1, value_1> where
__DieselInternal: diesel::backend::Backend,
value_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_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: NotBlob, value_1> QueryFragment<crate::sqlite::Sqlite> for
json_array_1<V1, value_1> where
value_1: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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: NotBlob, value_1, __DieselInternal>
ValidGrouping<__DieselInternal> for json_array_1<V1, value_1> where
__Derived<value_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<value_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The `json_array()` SQL function accepts zero or more arguments and returns a well-formed JSON array"]
#[doc =
" that is composed from those arguments. Note that arguments of type BLOB will not be accepted by this"]
#[doc = " function."]
#[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_array_0`, `json_array_1`, ... `json_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_array")]
#[doc = ""]
#[doc =
" An argument with SQL type TEXT is normally converted into a quoted JSON string. However, if the"]
#[doc =
" argument is the output from another json function, then it is stored as JSON. This allows calls to"]
#[doc =
" `json_array()` and `json_object()` to be nested. The [`json()`] function can also be used to force"]
#[doc = " strings to be recognized as JSON."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Text, Double};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc =
" let result = diesel::select(json_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(json_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_array_2<V1: NotBlob, V2: NotBlob, value_1,
value_2>(value_1: value_1, value_2: value_2)
-> json_array_2<V1, V2, value_1, value_2> where
value_1: diesel::expression::AsExpression<V1>,
value_2: diesel::expression::AsExpression<V2> {
json_array_2_utils::json_array_2 {
value_1: value_1.as_expression(),
value_2: value_2.as_expression(),
V1: ::std::marker::PhantomData,
V2: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_array_2()`](fn@json_array_2)"]
pub type json_array_2<V1, V2, value_1, value_2> =
json_array_2_utils::json_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_array_2_return_type {
#[doc =
"Return type of the [`json_array_2()`](fn@super::json_array_2) SQL function."]
pub type json_array_2<value_1, value_2> =
super::json_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_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_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: ::std::marker::PhantomData<V1>,
pub(in super) V2: ::std::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> ::std::ops::Add<__Rhs> for
json_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> ::std::ops::Sub<__Rhs> for
json_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> ::std::ops::Mul<__Rhs> for
json_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> ::std::ops::Div<__Rhs> for
json_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_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_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_array_2<V1, V2, value_1, value_2> {
#[inline]
fn clone(&self) -> json_array_2<V1, V2, value_1, value_2> {
json_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_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_array_2<V1, V2, value_1, value_2> {
type QueryId =
json_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_array_2()`](fn@json_array_2)"]
pub type HelperType<V1, V2, value_1, value_2> =
json_array_2<V1, V2, <value_1 as AsExpression<V1>>::Expression,
<value_2 as AsExpression<V2>>::Expression>;
impl<V1: NotBlob, V2: NotBlob, value_1, value_2> Expression for
json_array_2<V1, V2, value_1, value_2> where
(value_1, value_2): Expression {
type SqlType = Json;
}
impl<V1: NotBlob, V2: NotBlob, value_1, value_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_array_2<V1, V2, value_1, value_2> where
value_1: SelectableExpression<__DieselInternal>,
value_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<V1: NotBlob, V2: NotBlob, value_1, value_2, __DieselInternal>
AppearsOnTable<__DieselInternal> for
json_array_2<V1, V2, value_1, value_2> where
value_1: AppearsOnTable<__DieselInternal>,
value_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<V1: NotBlob, V2: NotBlob, value_1, value_2, __DieselInternal>
FunctionFragment<__DieselInternal> for
json_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_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: NotBlob, V2: NotBlob, value_1, value_2>
QueryFragment<crate::sqlite::Sqlite> for
json_array_2<V1, V2, value_1, value_2> where
value_1: QueryFragment<crate::sqlite::Sqlite>,
value_2: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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: NotBlob, V2: NotBlob, value_1, value_2, __DieselInternal>
ValidGrouping<__DieselInternal> for
json_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_array_return_types {
#[doc(inline)]
pub use super::__json_array_0_return_type::*;
#[doc(inline)]
pub use super::__json_array_1_return_type::*;
#[doc(inline)]
pub use super::__json_array_2_return_type::*;
}
#[doc =
" The `jsonb_array()` SQL function accepts zero or more arguments and returns a well-formed JSON array"]
#[doc =
" that is composed from those arguments. Note that arguments of type BLOB will not be accepted by this"]
#[doc = " function."]
#[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_array_0`, `jsonb_array_1`, ... `jsonb_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_array")]
#[doc = ""]
#[doc =
" An argument with SQL type TEXT is normally converted into a quoted JSON string. However, if the"]
#[doc =
" argument is the output from another json function, then it is stored as JSON. This allows calls to"]
#[doc =
" `jsonb_array()` and `jsonb_object()` to be nested. The [`json()`] function can also be used to force"]
#[doc = " strings to be recognized as JSON."]
#[doc = ""]
#[doc =
" This function works just like the [`json_array()`](json_array_1()) function except that it returns the"]
#[doc =
" constructed JSON array in the SQLite\'s private JSONB format rather than in the standard RFC 8259 text"]
#[doc = " format."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Text, Double};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc =
" let result = diesel::select(jsonb_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(jsonb_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_array_0() -> jsonb_array_0 where {
jsonb_array_0_utils::jsonb_array_0 {}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_array_0()`](fn@jsonb_array_0)"]
pub type jsonb_array_0 = jsonb_array_0_utils::jsonb_array_0<>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_array_0_return_type {
#[doc =
"Return type of the [`jsonb_array_0()`](fn@super::jsonb_array_0) SQL function."]
pub type jsonb_array_0 = super::jsonb_array_0<>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_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_array_0 {}
#[automatically_derived]
impl ::core::fmt::Debug for jsonb_array_0 {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "jsonb_array_0")
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for jsonb_array_0 { }
#[automatically_derived]
impl ::core::clone::Clone for jsonb_array_0 {
#[inline]
fn clone(&self) -> jsonb_array_0 { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for jsonb_array_0 { }
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for jsonb_array_0 {
type QueryId = jsonb_array_0<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[doc = "The return type of [`jsonb_array_0()`](fn@jsonb_array_0)"]
pub type HelperType = jsonb_array_0<>;
impl Expression for jsonb_array_0 where {
type SqlType = Jsonb;
}
impl<__DieselInternal> SelectableExpression<__DieselInternal> for
jsonb_array_0 where Self: AppearsOnTable<__DieselInternal> {}
impl<__DieselInternal> AppearsOnTable<__DieselInternal> for jsonb_array_0
where Self: Expression {}
impl<__DieselInternal> FunctionFragment<__DieselInternal> for
jsonb_array_0 where __DieselInternal: diesel::backend::Backend {
const FUNCTION_NAME: &'static str = "jsonb_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::sqlite::Sqlite> for jsonb_array_0 where {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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_array_0
where __Derived<>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The `jsonb_array()` SQL function accepts zero or more arguments and returns a well-formed JSON array"]
#[doc =
" that is composed from those arguments. Note that arguments of type BLOB will not be accepted by this"]
#[doc = " function."]
#[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_array_0`, `jsonb_array_1`, ... `jsonb_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_array")]
#[doc = ""]
#[doc =
" An argument with SQL type TEXT is normally converted into a quoted JSON string. However, if the"]
#[doc =
" argument is the output from another json function, then it is stored as JSON. This allows calls to"]
#[doc =
" `jsonb_array()` and `jsonb_object()` to be nested. The [`json()`] function can also be used to force"]
#[doc = " strings to be recognized as JSON."]
#[doc = ""]
#[doc =
" This function works just like the [`json_array()`](json_array_1()) function except that it returns the"]
#[doc =
" constructed JSON array in the SQLite\'s private JSONB format rather than in the standard RFC 8259 text"]
#[doc = " format."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Text, Double};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc =
" let result = diesel::select(jsonb_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(jsonb_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_array_1<V1: NotBlob, value_1>(value_1: value_1)
-> jsonb_array_1<V1, value_1> where
value_1: diesel::expression::AsExpression<V1> {
jsonb_array_1_utils::jsonb_array_1 {
value_1: value_1.as_expression(),
V1: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_array_1()`](fn@jsonb_array_1)"]
pub type jsonb_array_1<V1, value_1> =
jsonb_array_1_utils::jsonb_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_array_1_return_type {
#[doc =
"Return type of the [`jsonb_array_1()`](fn@super::jsonb_array_1) SQL function."]
pub type jsonb_array_1<value_1> =
super::jsonb_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_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_array_1<V1, value_1> {
pub(in super) value_1: value_1,
pub(in super) V1: ::std::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> ::std::ops::Add<__Rhs> for
jsonb_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> ::std::ops::Sub<__Rhs> for
jsonb_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> ::std::ops::Mul<__Rhs> for
jsonb_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> ::std::ops::Div<__Rhs> for
jsonb_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_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_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_array_1<V1, value_1> {
#[inline]
fn clone(&self) -> jsonb_array_1<V1, value_1> {
jsonb_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_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_array_1<V1, value_1>
{
type QueryId =
jsonb_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_array_1()`](fn@jsonb_array_1)"]
pub type HelperType<V1, value_1> =
jsonb_array_1<V1, <value_1 as AsExpression<V1>>::Expression>;
impl<V1: NotBlob, value_1> Expression for jsonb_array_1<V1, value_1> where
(value_1): Expression {
type SqlType = Jsonb;
}
impl<V1: NotBlob, value_1, __DieselInternal>
SelectableExpression<__DieselInternal> for jsonb_array_1<V1, value_1>
where value_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<V1: NotBlob, value_1, __DieselInternal>
AppearsOnTable<__DieselInternal> for jsonb_array_1<V1, value_1> where
value_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<V1: NotBlob, value_1, __DieselInternal>
FunctionFragment<__DieselInternal> for jsonb_array_1<V1, value_1>
where __DieselInternal: diesel::backend::Backend,
value_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_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: NotBlob, value_1> QueryFragment<crate::sqlite::Sqlite> for
jsonb_array_1<V1, value_1> where
value_1: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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: NotBlob, value_1, __DieselInternal>
ValidGrouping<__DieselInternal> for jsonb_array_1<V1, value_1> where
__Derived<value_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<value_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The `jsonb_array()` SQL function accepts zero or more arguments and returns a well-formed JSON array"]
#[doc =
" that is composed from those arguments. Note that arguments of type BLOB will not be accepted by this"]
#[doc = " function."]
#[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_array_0`, `jsonb_array_1`, ... `jsonb_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_array")]
#[doc = ""]
#[doc =
" An argument with SQL type TEXT is normally converted into a quoted JSON string. However, if the"]
#[doc =
" argument is the output from another json function, then it is stored as JSON. This allows calls to"]
#[doc =
" `jsonb_array()` and `jsonb_object()` to be nested. The [`json()`] function can also be used to force"]
#[doc = " strings to be recognized as JSON."]
#[doc = ""]
#[doc =
" This function works just like the [`json_array()`](json_array_1()) function except that it returns the"]
#[doc =
" constructed JSON array in the SQLite\'s private JSONB format rather than in the standard RFC 8259 text"]
#[doc = " format."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Text, Double};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc =
" let result = diesel::select(jsonb_array_0()).get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([]), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(jsonb_array_1::<Text, _>(\"abc\"))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\"]), result);"]
#[doc = ""]
#[doc =
" let result = diesel::select(jsonb_array_2::<Text, Double, _, _>(\"abc\", 3.1415))"]
#[doc = " .get_result::<serde_json::Value>(connection)?;"]
#[doc = " assert_eq!(json!([\"abc\", 3.1415]), result);"]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_array_2<V1: NotBlob, V2: NotBlob, value_1,
value_2>(value_1: value_1, value_2: value_2)
-> jsonb_array_2<V1, V2, value_1, value_2> where
value_1: diesel::expression::AsExpression<V1>,
value_2: diesel::expression::AsExpression<V2> {
jsonb_array_2_utils::jsonb_array_2 {
value_1: value_1.as_expression(),
value_2: value_2.as_expression(),
V1: ::std::marker::PhantomData,
V2: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_array_2()`](fn@jsonb_array_2)"]
pub type jsonb_array_2<V1, V2, value_1, value_2> =
jsonb_array_2_utils::jsonb_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_array_2_return_type {
#[doc =
"Return type of the [`jsonb_array_2()`](fn@super::jsonb_array_2) SQL function."]
pub type jsonb_array_2<value_1, value_2> =
super::jsonb_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_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_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: ::std::marker::PhantomData<V1>,
pub(in super) V2: ::std::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> ::std::ops::Add<__Rhs> for
jsonb_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> ::std::ops::Sub<__Rhs> for
jsonb_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> ::std::ops::Mul<__Rhs> for
jsonb_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> ::std::ops::Div<__Rhs> for
jsonb_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_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_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_array_2<V1, V2, value_1, value_2> {
#[inline]
fn clone(&self) -> jsonb_array_2<V1, V2, value_1, value_2> {
jsonb_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_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_array_2<V1, V2, value_1, value_2> {
type QueryId =
jsonb_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_array_2()`](fn@jsonb_array_2)"]
pub type HelperType<V1, V2, value_1, value_2> =
jsonb_array_2<V1, V2, <value_1 as AsExpression<V1>>::Expression,
<value_2 as AsExpression<V2>>::Expression>;
impl<V1: NotBlob, V2: NotBlob, value_1, value_2> Expression for
jsonb_array_2<V1, V2, value_1, value_2> where
(value_1, value_2): Expression {
type SqlType = Jsonb;
}
impl<V1: NotBlob, V2: NotBlob, value_1, value_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_array_2<V1, V2, value_1, value_2> where
value_1: SelectableExpression<__DieselInternal>,
value_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<V1: NotBlob, V2: NotBlob, value_1, value_2, __DieselInternal>
AppearsOnTable<__DieselInternal> for
jsonb_array_2<V1, V2, value_1, value_2> where
value_1: AppearsOnTable<__DieselInternal>,
value_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<V1: NotBlob, V2: NotBlob, value_1, value_2, __DieselInternal>
FunctionFragment<__DieselInternal> for
jsonb_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_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: NotBlob, V2: NotBlob, value_1, value_2>
QueryFragment<crate::sqlite::Sqlite> for
jsonb_array_2<V1, V2, value_1, value_2> where
value_1: QueryFragment<crate::sqlite::Sqlite>,
value_2: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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: NotBlob, V2: NotBlob, value_1, value_2, __DieselInternal>
ValidGrouping<__DieselInternal> for
jsonb_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_array_return_types {
#[doc(inline)]
pub use super::__jsonb_array_0_return_type::*;
#[doc(inline)]
pub use super::__jsonb_array_1_return_type::*;
#[doc(inline)]
pub use super::__jsonb_array_2_return_type::*;
}
#[doc =
" The `json_remove(X,P,...)` SQL function takes a single JSON value as its first argument followed by"]
#[doc =
" zero or more path arguments. The `json_remove(X,P,...)` function returns a copy of the X parameter"]
#[doc =
" with all the elements identified by path arguments removed. Paths that select elements not found in X"]
#[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_remove_0`, `json_remove_1`, ... `json_remove_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_remove")]
#[doc = " are silently ignored."]
#[doc = ""]
#[doc =
" Removals occurs sequentially from left to right. Changes caused by prior removals can affect the path"]
#[doc = " search for subsequent arguments."]
#[doc = ""]
#[doc =
" If the `json_remove(X)` function is called with no path arguments, then it returns the input X"]
#[doc = " reformatted, with excess whitespace removed."]
#[doc = ""]
#[doc =
" The `json_remove()` function throws an error if any of the path arguments is not a well-formed path."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Json, Text};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc = " let result = diesel::select(json_remove_0::<Json, _>(json))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'a\', \'b\', \'c\', \'d\'])), result);"]
#[doc = ""]
#[doc = " // Values are removed sequentially from left to right."]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc =
" let result = diesel::select(json_remove_2::<Json, _, _, _>(json, \"$[0]\", \"$[2]\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'b\', \'c\'])), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(json_remove_1::<Json, _, _>(json, \"$.a\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"b\": 20})), result);"]
#[doc = ""]
#[doc = " // Paths that select not existing elements are silently ignored."]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(json_remove_1::<Json, _, _>(json, \"$.c\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"a\": 10, \"b\": 20})), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(json_remove_1::<Json, _, _>(json, \"$\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_remove_0<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
SingleValue, json>(json: json) -> json_remove_0<J, json> where
json: diesel::expression::AsExpression<J> {
json_remove_0_utils::json_remove_0 {
json: json.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_remove_0()`](fn@json_remove_0)"]
pub type json_remove_0<J, json> =
json_remove_0_utils::json_remove_0<J,
<json as diesel::expression::AsExpression<J>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_remove_0_return_type {
#[doc =
"Return type of the [`json_remove_0()`](fn@super::json_remove_0) SQL function."]
pub type json_remove_0<json> =
super::json_remove_0<<json as
diesel::expression::Expression>::SqlType, json>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_remove_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_remove_0<J, json> {
pub(in super) json: json,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, json, __Rhs> ::std::ops::Add<__Rhs> for
json_remove_0<J, 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<J, json, __Rhs> ::std::ops::Sub<__Rhs> for
json_remove_0<J, 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<J, json, __Rhs> ::std::ops::Mul<__Rhs> for
json_remove_0<J, 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<J, json, __Rhs> ::std::ops::Div<__Rhs> for
json_remove_0<J, 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<J: ::core::fmt::Debug, json: ::core::fmt::Debug> ::core::fmt::Debug
for json_remove_0<J, json> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"json_remove_0", "json", &self.json, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, json: ::core::clone::Clone>
::core::clone::Clone for json_remove_0<J, json> {
#[inline]
fn clone(&self) -> json_remove_0<J, json> {
json_remove_0 {
json: ::core::clone::Clone::clone(&self.json),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, json: ::core::marker::Copy>
::core::marker::Copy for json_remove_0<J, json> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for json_remove_0<J, json> {
type QueryId =
json_remove_0<<J as
diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J 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 =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
|| false;
}
};
#[doc = "The return type of [`json_remove_0()`](fn@json_remove_0)"]
pub type HelperType<J, json> =
json_remove_0<J, <json as AsExpression<J>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json>
Expression for json_remove_0<J, json> where (json): Expression {
type SqlType = Nullable<Json>;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
__DieselInternal> SelectableExpression<__DieselInternal> for
json_remove_0<J, json> where
json: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
__DieselInternal> AppearsOnTable<__DieselInternal> for
json_remove_0<J, json> where json: AppearsOnTable<__DieselInternal>,
Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
__DieselInternal> FunctionFragment<__DieselInternal> for
json_remove_0<J, json> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_remove";
#[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<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json>
QueryFragment<crate::sqlite::Sqlite> for json_remove_0<J, json> where
json: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
__DieselInternal> ValidGrouping<__DieselInternal> for
json_remove_0<J, json> where
__Derived<json>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The `json_remove(X,P,...)` SQL function takes a single JSON value as its first argument followed by"]
#[doc =
" zero or more path arguments. The `json_remove(X,P,...)` function returns a copy of the X parameter"]
#[doc =
" with all the elements identified by path arguments removed. Paths that select elements not found in X"]
#[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_remove_0`, `json_remove_1`, ... `json_remove_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_remove")]
#[doc = " are silently ignored."]
#[doc = ""]
#[doc =
" Removals occurs sequentially from left to right. Changes caused by prior removals can affect the path"]
#[doc = " search for subsequent arguments."]
#[doc = ""]
#[doc =
" If the `json_remove(X)` function is called with no path arguments, then it returns the input X"]
#[doc = " reformatted, with excess whitespace removed."]
#[doc = ""]
#[doc =
" The `json_remove()` function throws an error if any of the path arguments is not a well-formed path."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Json, Text};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc = " let result = diesel::select(json_remove_0::<Json, _>(json))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'a\', \'b\', \'c\', \'d\'])), result);"]
#[doc = ""]
#[doc = " // Values are removed sequentially from left to right."]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc =
" let result = diesel::select(json_remove_2::<Json, _, _, _>(json, \"$[0]\", \"$[2]\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'b\', \'c\'])), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(json_remove_1::<Json, _, _>(json, \"$.a\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"b\": 20})), result);"]
#[doc = ""]
#[doc = " // Paths that select not existing elements are silently ignored."]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(json_remove_1::<Json, _, _>(json, \"$.c\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"a\": 10, \"b\": 20})), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(json_remove_1::<Json, _, _>(json, \"$\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_remove_1<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
SingleValue, json, path_1>(json: json, path_1: path_1)
-> json_remove_1<J, json, path_1> where
json: diesel::expression::AsExpression<J>,
path_1: diesel::expression::AsExpression<Text> {
json_remove_1_utils::json_remove_1 {
json: json.as_expression(),
path_1: path_1.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_remove_1()`](fn@json_remove_1)"]
pub type json_remove_1<J, json, path_1> =
json_remove_1_utils::json_remove_1<J,
<json as diesel::expression::AsExpression<J>>::Expression,
<path_1 as diesel::expression::AsExpression<Text>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_remove_1_return_type {
#[doc =
"Return type of the [`json_remove_1()`](fn@super::json_remove_1) SQL function."]
pub type json_remove_1<json, path_1> =
super::json_remove_1<<json as
diesel::expression::Expression>::SqlType, json, path_1>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_remove_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_remove_1<J, json, path_1> {
pub(in super) json: json,
pub(in super) path_1: path_1,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, json, path_1, __Rhs> ::std::ops::Add<__Rhs> for
json_remove_1<J, json, path_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, json, path_1, __Rhs> ::std::ops::Sub<__Rhs> for
json_remove_1<J, json, path_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, json, path_1, __Rhs> ::std::ops::Mul<__Rhs> for
json_remove_1<J, json, path_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, json, path_1, __Rhs> ::std::ops::Div<__Rhs> for
json_remove_1<J, json, path_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, json: ::core::fmt::Debug,
path_1: ::core::fmt::Debug> ::core::fmt::Debug for
json_remove_1<J, json, path_1> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"json_remove_1", "json", &self.json, "path_1", &self.path_1,
"J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, json: ::core::clone::Clone,
path_1: ::core::clone::Clone> ::core::clone::Clone for
json_remove_1<J, json, path_1> {
#[inline]
fn clone(&self) -> json_remove_1<J, json, path_1> {
json_remove_1 {
json: ::core::clone::Clone::clone(&self.json),
path_1: ::core::clone::Clone::clone(&self.path_1),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, json: ::core::marker::Copy,
path_1: ::core::marker::Copy> ::core::marker::Copy for
json_remove_1<J, json, path_1> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
path_1: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_remove_1<J, json, path_1> {
type QueryId =
json_remove_1<<J as
diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<path_1 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<path_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 ||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<path_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`json_remove_1()`](fn@json_remove_1)"]
pub type HelperType<J, json, path_1> =
json_remove_1<J, <json as AsExpression<J>>::Expression,
<path_1 as AsExpression<Text>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1> Expression for json_remove_1<J, json, path_1> where
(json, path_1): Expression {
type SqlType = Nullable<Json>;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, __DieselInternal> SelectableExpression<__DieselInternal> for
json_remove_1<J, json, path_1> where
json: SelectableExpression<__DieselInternal>,
path_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, __DieselInternal> AppearsOnTable<__DieselInternal> for
json_remove_1<J, json, path_1> where
json: AppearsOnTable<__DieselInternal>,
path_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, __DieselInternal> FunctionFragment<__DieselInternal> for
json_remove_1<J, json, path_1> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
path_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_remove";
#[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.path_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.path_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1> QueryFragment<crate::sqlite::Sqlite> for
json_remove_1<J, json, path_1> where
json: QueryFragment<crate::sqlite::Sqlite>,
path_1: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<json, path_1>(json, path_1);
const _: () =
{
use diesel;
impl<json, path_1, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, path_1> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
path_1: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<path_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, __DieselInternal> ValidGrouping<__DieselInternal> for
json_remove_1<J, json, path_1> where
__Derived<json, path_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, path_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The `json_remove(X,P,...)` SQL function takes a single JSON value as its first argument followed by"]
#[doc =
" zero or more path arguments. The `json_remove(X,P,...)` function returns a copy of the X parameter"]
#[doc =
" with all the elements identified by path arguments removed. Paths that select elements not found in X"]
#[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_remove_0`, `json_remove_1`, ... `json_remove_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_remove")]
#[doc = " are silently ignored."]
#[doc = ""]
#[doc =
" Removals occurs sequentially from left to right. Changes caused by prior removals can affect the path"]
#[doc = " search for subsequent arguments."]
#[doc = ""]
#[doc =
" If the `json_remove(X)` function is called with no path arguments, then it returns the input X"]
#[doc = " reformatted, with excess whitespace removed."]
#[doc = ""]
#[doc =
" The `json_remove()` function throws an error if any of the path arguments is not a well-formed path."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Json, Text};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc = " let result = diesel::select(json_remove_0::<Json, _>(json))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'a\', \'b\', \'c\', \'d\'])), result);"]
#[doc = ""]
#[doc = " // Values are removed sequentially from left to right."]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc =
" let result = diesel::select(json_remove_2::<Json, _, _, _>(json, \"$[0]\", \"$[2]\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'b\', \'c\'])), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(json_remove_1::<Json, _, _>(json, \"$.a\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"b\": 20})), result);"]
#[doc = ""]
#[doc = " // Paths that select not existing elements are silently ignored."]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(json_remove_1::<Json, _, _>(json, \"$.c\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"a\": 10, \"b\": 20})), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(json_remove_1::<Json, _, _>(json, \"$\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_remove_2<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
SingleValue, json, path_1,
path_2>(json: json, path_1: path_1, path_2: path_2)
-> json_remove_2<J, json, path_1, path_2> where
json: diesel::expression::AsExpression<J>,
path_1: diesel::expression::AsExpression<Text>,
path_2: diesel::expression::AsExpression<Text> {
json_remove_2_utils::json_remove_2 {
json: json.as_expression(),
path_1: path_1.as_expression(),
path_2: path_2.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_remove_2()`](fn@json_remove_2)"]
pub type json_remove_2<J, json, path_1, path_2> =
json_remove_2_utils::json_remove_2<J,
<json as diesel::expression::AsExpression<J>>::Expression,
<path_1 as diesel::expression::AsExpression<Text>>::Expression,
<path_2 as diesel::expression::AsExpression<Text>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_remove_2_return_type {
#[doc =
"Return type of the [`json_remove_2()`](fn@super::json_remove_2) SQL function."]
pub type json_remove_2<json, path_1, path_2> =
super::json_remove_2<<json as
diesel::expression::Expression>::SqlType, json, path_1, path_2>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_remove_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_remove_2<J, json, path_1, path_2> {
pub(in super) json: json,
pub(in super) path_1: path_1,
pub(in super) path_2: path_2,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, json, path_1, path_2, __Rhs> ::std::ops::Add<__Rhs> for
json_remove_2<J, json, path_1, path_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, json, path_1, path_2, __Rhs> ::std::ops::Sub<__Rhs> for
json_remove_2<J, json, path_1, path_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, json, path_1, path_2, __Rhs> ::std::ops::Mul<__Rhs> for
json_remove_2<J, json, path_1, path_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, json, path_1, path_2, __Rhs> ::std::ops::Div<__Rhs> for
json_remove_2<J, json, path_1, path_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, json: ::core::fmt::Debug,
path_1: ::core::fmt::Debug, path_2: ::core::fmt::Debug>
::core::fmt::Debug for json_remove_2<J, json, path_1, path_2> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"json_remove_2", "json", &self.json, "path_1", &self.path_1,
"path_2", &self.path_2, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, json: ::core::clone::Clone,
path_1: ::core::clone::Clone, path_2: ::core::clone::Clone>
::core::clone::Clone for json_remove_2<J, json, path_1, path_2> {
#[inline]
fn clone(&self) -> json_remove_2<J, json, path_1, path_2> {
json_remove_2 {
json: ::core::clone::Clone::clone(&self.json),
path_1: ::core::clone::Clone::clone(&self.path_1),
path_2: ::core::clone::Clone::clone(&self.path_2),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, json: ::core::marker::Copy,
path_1: ::core::marker::Copy, path_2: ::core::marker::Copy>
::core::marker::Copy for json_remove_2<J, json, path_1, path_2> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
path_1: diesel::query_builder::QueryId,
path_2: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_remove_2<J, json, path_1, path_2> {
type QueryId =
json_remove_2<<J as
diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<path_1 as diesel::query_builder::QueryId>::QueryId,
<path_2 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<path_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<path_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 ||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<path_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<path_2 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`json_remove_2()`](fn@json_remove_2)"]
pub type HelperType<J, json, path_1, path_2> =
json_remove_2<J, <json as AsExpression<J>>::Expression,
<path_1 as AsExpression<Text>>::Expression,
<path_2 as AsExpression<Text>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2> Expression for json_remove_2<J, json, path_1, path_2>
where (json, path_1, path_2): Expression {
type SqlType = Nullable<Json>;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_remove_2<J, json, path_1, path_2> where
json: SelectableExpression<__DieselInternal>,
path_1: SelectableExpression<__DieselInternal>,
path_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2, __DieselInternal> AppearsOnTable<__DieselInternal> for
json_remove_2<J, json, path_1, path_2> where
json: AppearsOnTable<__DieselInternal>,
path_1: AppearsOnTable<__DieselInternal>,
path_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2, __DieselInternal> FunctionFragment<__DieselInternal>
for json_remove_2<J, json, path_1, path_2> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
path_1: QueryFragment<__DieselInternal>,
path_2: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_remove";
#[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.path_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.path_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.path_2.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.path_2.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2> QueryFragment<crate::sqlite::Sqlite> for
json_remove_2<J, json, path_1, path_2> where
json: QueryFragment<crate::sqlite::Sqlite>,
path_1: QueryFragment<crate::sqlite::Sqlite>,
path_2: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<json, path_1, path_2>(json, path_1, path_2);
const _: () =
{
use diesel;
impl<json, path_1, path_2, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, path_1, path_2> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
path_1: diesel::expression::ValidGrouping<__GroupByClause>,
path_2: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<path_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<path_2
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<path_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
as
diesel::expression::MixedAggregates<<path_2 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2, __DieselInternal> ValidGrouping<__DieselInternal> for
json_remove_2<J, json, path_1, path_2> where
__Derived<json, path_1, path_2>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, path_1, path_2> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[allow(unused_imports)]
#[doc(inline)]
mod __json_remove_return_types {
#[doc(inline)]
pub use super::__json_remove_0_return_type::*;
#[doc(inline)]
pub use super::__json_remove_1_return_type::*;
#[doc(inline)]
pub use super::__json_remove_2_return_type::*;
}
#[doc =
" The `jsonb_remove(X,P,...)` SQL function takes a single JSON value as its first argument followed by"]
#[doc =
" zero or more path arguments. The `jsonb_remove(X,P,...)` function returns a copy of the X parameter"]
#[doc =
" with all the elements identified by path arguments removed. Paths that select elements not found in X"]
#[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_remove_0`, `jsonb_remove_1`, ... `jsonb_remove_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_remove")]
#[doc = " are silently ignored."]
#[doc = ""]
#[doc =
" Removals occurs sequentially from left to right. Changes caused by prior removals can affect the path"]
#[doc = " search for subsequent arguments."]
#[doc = ""]
#[doc =
" If the `jsonb_remove(X)` function is called with no path arguments, then it returns the input X"]
#[doc = " reformatted, with excess whitespace removed."]
#[doc = ""]
#[doc =
" The `jsonb_remove()` function throws an error if any of the path arguments is not a well-formed path."]
#[doc = ""]
#[doc = " This function returns value in a binary JSONB format."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Jsonb, Text};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc = " let result = diesel::select(jsonb_remove_0::<Jsonb, _>(json))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'a\', \'b\', \'c\', \'d\'])), result);"]
#[doc = ""]
#[doc = " // Values are removed sequentially from left to right."]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc =
" let result = diesel::select(jsonb_remove_2::<Jsonb, _, _, _>(json, \"$[0]\", \"$[2]\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'b\', \'c\'])), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(jsonb_remove_1::<Jsonb, _, _>(json, \"$.a\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"b\": 20})), result);"]
#[doc = ""]
#[doc = " // Paths that select not existing elements are silently ignored."]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(jsonb_remove_1::<Jsonb, _, _>(json, \"$.c\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"a\": 10, \"b\": 20})), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(jsonb_remove_1::<Jsonb, _, _>(json, \"$\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_remove_0<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
SingleValue, json>(json: json) -> jsonb_remove_0<J, json> where
json: diesel::expression::AsExpression<J> {
jsonb_remove_0_utils::jsonb_remove_0 {
json: json.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_remove_0()`](fn@jsonb_remove_0)"]
pub type jsonb_remove_0<J, json> =
jsonb_remove_0_utils::jsonb_remove_0<J,
<json as diesel::expression::AsExpression<J>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_remove_0_return_type {
#[doc =
"Return type of the [`jsonb_remove_0()`](fn@super::jsonb_remove_0) SQL function."]
pub type jsonb_remove_0<json> =
super::jsonb_remove_0<<json as
diesel::expression::Expression>::SqlType, json>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_remove_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_remove_0<J, json> {
pub(in super) json: json,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, json, __Rhs> ::std::ops::Add<__Rhs> for
jsonb_remove_0<J, 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<J, json, __Rhs> ::std::ops::Sub<__Rhs> for
jsonb_remove_0<J, 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<J, json, __Rhs> ::std::ops::Mul<__Rhs> for
jsonb_remove_0<J, 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<J, json, __Rhs> ::std::ops::Div<__Rhs> for
jsonb_remove_0<J, 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<J: ::core::fmt::Debug, json: ::core::fmt::Debug> ::core::fmt::Debug
for jsonb_remove_0<J, json> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"jsonb_remove_0", "json", &self.json, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, json: ::core::clone::Clone>
::core::clone::Clone for jsonb_remove_0<J, json> {
#[inline]
fn clone(&self) -> jsonb_remove_0<J, json> {
jsonb_remove_0 {
json: ::core::clone::Clone::clone(&self.json),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, json: ::core::marker::Copy>
::core::marker::Copy for jsonb_remove_0<J, json> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for jsonb_remove_0<J, json> {
type QueryId =
jsonb_remove_0<<J as
diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J 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 =
<J as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
|| false;
}
};
#[doc = "The return type of [`jsonb_remove_0()`](fn@jsonb_remove_0)"]
pub type HelperType<J, json> =
jsonb_remove_0<J, <json as AsExpression<J>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json>
Expression for jsonb_remove_0<J, json> where (json): Expression {
type SqlType = Nullable<Jsonb>;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
__DieselInternal> SelectableExpression<__DieselInternal> for
jsonb_remove_0<J, json> where
json: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
__DieselInternal> AppearsOnTable<__DieselInternal> for
jsonb_remove_0<J, json> where json: AppearsOnTable<__DieselInternal>,
Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
__DieselInternal> FunctionFragment<__DieselInternal> for
jsonb_remove_0<J, json> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_remove";
#[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<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json>
QueryFragment<crate::sqlite::Sqlite> for jsonb_remove_0<J, json> where
json: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::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<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
__DieselInternal> ValidGrouping<__DieselInternal> for
jsonb_remove_0<J, json> where
__Derived<json>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The `jsonb_remove(X,P,...)` SQL function takes a single JSON value as its first argument followed by"]
#[doc =
" zero or more path arguments. The `jsonb_remove(X,P,...)` function returns a copy of the X parameter"]
#[doc =
" with all the elements identified by path arguments removed. Paths that select elements not found in X"]
#[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_remove_0`, `jsonb_remove_1`, ... `jsonb_remove_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_remove")]
#[doc = " are silently ignored."]
#[doc = ""]
#[doc =
" Removals occurs sequentially from left to right. Changes caused by prior removals can affect the path"]
#[doc = " search for subsequent arguments."]
#[doc = ""]
#[doc =
" If the `jsonb_remove(X)` function is called with no path arguments, then it returns the input X"]
#[doc = " reformatted, with excess whitespace removed."]
#[doc = ""]
#[doc =
" The `jsonb_remove()` function throws an error if any of the path arguments is not a well-formed path."]
#[doc = ""]
#[doc = " This function returns value in a binary JSONB format."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Jsonb, Text};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc = " let result = diesel::select(jsonb_remove_0::<Jsonb, _>(json))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'a\', \'b\', \'c\', \'d\'])), result);"]
#[doc = ""]
#[doc = " // Values are removed sequentially from left to right."]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc =
" let result = diesel::select(jsonb_remove_2::<Jsonb, _, _, _>(json, \"$[0]\", \"$[2]\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'b\', \'c\'])), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(jsonb_remove_1::<Jsonb, _, _>(json, \"$.a\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"b\": 20})), result);"]
#[doc = ""]
#[doc = " // Paths that select not existing elements are silently ignored."]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(jsonb_remove_1::<Jsonb, _, _>(json, \"$.c\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"a\": 10, \"b\": 20})), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(jsonb_remove_1::<Jsonb, _, _>(json, \"$\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_remove_1<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
SingleValue, json, path_1>(json: json, path_1: path_1)
-> jsonb_remove_1<J, json, path_1> where
json: diesel::expression::AsExpression<J>,
path_1: diesel::expression::AsExpression<Text> {
jsonb_remove_1_utils::jsonb_remove_1 {
json: json.as_expression(),
path_1: path_1.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_remove_1()`](fn@jsonb_remove_1)"]
pub type jsonb_remove_1<J, json, path_1> =
jsonb_remove_1_utils::jsonb_remove_1<J,
<json as diesel::expression::AsExpression<J>>::Expression,
<path_1 as diesel::expression::AsExpression<Text>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_remove_1_return_type {
#[doc =
"Return type of the [`jsonb_remove_1()`](fn@super::jsonb_remove_1) SQL function."]
pub type jsonb_remove_1<json, path_1> =
super::jsonb_remove_1<<json as
diesel::expression::Expression>::SqlType, json, path_1>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_remove_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_remove_1<J, json, path_1> {
pub(in super) json: json,
pub(in super) path_1: path_1,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, json, path_1, __Rhs> ::std::ops::Add<__Rhs> for
jsonb_remove_1<J, json, path_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, json, path_1, __Rhs> ::std::ops::Sub<__Rhs> for
jsonb_remove_1<J, json, path_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, json, path_1, __Rhs> ::std::ops::Mul<__Rhs> for
jsonb_remove_1<J, json, path_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, json, path_1, __Rhs> ::std::ops::Div<__Rhs> for
jsonb_remove_1<J, json, path_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, json: ::core::fmt::Debug,
path_1: ::core::fmt::Debug> ::core::fmt::Debug for
jsonb_remove_1<J, json, path_1> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"jsonb_remove_1", "json", &self.json, "path_1", &self.path_1,
"J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, json: ::core::clone::Clone,
path_1: ::core::clone::Clone> ::core::clone::Clone for
jsonb_remove_1<J, json, path_1> {
#[inline]
fn clone(&self) -> jsonb_remove_1<J, json, path_1> {
jsonb_remove_1 {
json: ::core::clone::Clone::clone(&self.json),
path_1: ::core::clone::Clone::clone(&self.path_1),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, json: ::core::marker::Copy,
path_1: ::core::marker::Copy> ::core::marker::Copy for
jsonb_remove_1<J, json, path_1> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
path_1: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_remove_1<J, json, path_1> {
type QueryId =
jsonb_remove_1<<J as
diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<path_1 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<path_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 ||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<path_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`jsonb_remove_1()`](fn@jsonb_remove_1)"]
pub type HelperType<J, json, path_1> =
jsonb_remove_1<J, <json as AsExpression<J>>::Expression,
<path_1 as AsExpression<Text>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1> Expression for jsonb_remove_1<J, json, path_1> where
(json, path_1): Expression {
type SqlType = Nullable<Jsonb>;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, __DieselInternal> SelectableExpression<__DieselInternal> for
jsonb_remove_1<J, json, path_1> where
json: SelectableExpression<__DieselInternal>,
path_1: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, __DieselInternal> AppearsOnTable<__DieselInternal> for
jsonb_remove_1<J, json, path_1> where
json: AppearsOnTable<__DieselInternal>,
path_1: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, __DieselInternal> FunctionFragment<__DieselInternal> for
jsonb_remove_1<J, json, path_1> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
path_1: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_remove";
#[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.path_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.path_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1> QueryFragment<crate::sqlite::Sqlite> for
jsonb_remove_1<J, json, path_1> where
json: QueryFragment<crate::sqlite::Sqlite>,
path_1: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<json, path_1>(json, path_1);
const _: () =
{
use diesel;
impl<json, path_1, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, path_1> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
path_1: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<path_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, __DieselInternal> ValidGrouping<__DieselInternal> for
jsonb_remove_1<J, json, path_1> where
__Derived<json, path_1>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, path_1> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" The `jsonb_remove(X,P,...)` SQL function takes a single JSON value as its first argument followed by"]
#[doc =
" zero or more path arguments. The `jsonb_remove(X,P,...)` function returns a copy of the X parameter"]
#[doc =
" with all the elements identified by path arguments removed. Paths that select elements not found in X"]
#[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_remove_0`, `jsonb_remove_1`, ... `jsonb_remove_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_remove")]
#[doc = " are silently ignored."]
#[doc = ""]
#[doc =
" Removals occurs sequentially from left to right. Changes caused by prior removals can affect the path"]
#[doc = " search for subsequent arguments."]
#[doc = ""]
#[doc =
" If the `jsonb_remove(X)` function is called with no path arguments, then it returns the input X"]
#[doc = " reformatted, with excess whitespace removed."]
#[doc = ""]
#[doc =
" The `jsonb_remove()` function throws an error if any of the path arguments is not a well-formed path."]
#[doc = ""]
#[doc = " This function returns value in a binary JSONB format."]
#[doc = ""]
#[doc = " This function requires at least SQLite 3.38 or newer"]
#[doc = ""]
#[doc = " # Examples"]
#[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::*;"]
#[doc = " # use diesel::sql_types::{Jsonb, Text};"]
#[doc = " # use serde_json::json;"]
#[doc = " #"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 38, 0);"]
#[doc = " #"]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc = " let result = diesel::select(jsonb_remove_0::<Jsonb, _>(json))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'a\', \'b\', \'c\', \'d\'])), result);"]
#[doc = ""]
#[doc = " // Values are removed sequentially from left to right."]
#[doc = " let json = json!([\'a\', \'b\', \'c\', \'d\']);"]
#[doc =
" let result = diesel::select(jsonb_remove_2::<Jsonb, _, _, _>(json, \"$[0]\", \"$[2]\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!([\'b\', \'c\'])), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(jsonb_remove_1::<Jsonb, _, _>(json, \"$.a\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"b\": 20})), result);"]
#[doc = ""]
#[doc = " // Paths that select not existing elements are silently ignored."]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(jsonb_remove_1::<Jsonb, _, _>(json, \"$.c\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(Some(json!({\"a\": 10, \"b\": 20})), result);"]
#[doc = ""]
#[doc = " let json = json!({\"a\": 10, \"b\": 20});"]
#[doc =
" let result = diesel::select(jsonb_remove_1::<Jsonb, _, _>(json, \"$\"))"]
#[doc = " .get_result::<Option<serde_json::Value>>(connection)?;"]
#[doc = " assert_eq!(None, result);"]
#[doc = ""]
#[doc = " #"]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_remove_2<J: JsonOrNullableJsonOrJsonbOrNullableJsonb +
SingleValue, json, path_1,
path_2>(json: json, path_1: path_1, path_2: path_2)
-> jsonb_remove_2<J, json, path_1, path_2> where
json: diesel::expression::AsExpression<J>,
path_1: diesel::expression::AsExpression<Text>,
path_2: diesel::expression::AsExpression<Text> {
jsonb_remove_2_utils::jsonb_remove_2 {
json: json.as_expression(),
path_1: path_1.as_expression(),
path_2: path_2.as_expression(),
J: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_remove_2()`](fn@jsonb_remove_2)"]
pub type jsonb_remove_2<J, json, path_1, path_2> =
jsonb_remove_2_utils::jsonb_remove_2<J,
<json as diesel::expression::AsExpression<J>>::Expression,
<path_1 as diesel::expression::AsExpression<Text>>::Expression,
<path_2 as diesel::expression::AsExpression<Text>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_remove_2_return_type {
#[doc =
"Return type of the [`jsonb_remove_2()`](fn@super::jsonb_remove_2) SQL function."]
pub type jsonb_remove_2<json, path_1, path_2> =
super::jsonb_remove_2<<json as
diesel::expression::Expression>::SqlType, json, path_1, path_2>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_remove_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_remove_2<J, json, path_1, path_2> {
pub(in super) json: json,
pub(in super) path_1: path_1,
pub(in super) path_2: path_2,
pub(in super) J: ::std::marker::PhantomData<J>,
}
const _: () =
{
use diesel;
use diesel::internal::derives::numeric_ops as ops;
use diesel::expression::{Expression, AsExpression};
use diesel::sql_types::ops::{Add, Sub, Mul, Div};
use diesel::sql_types::{SqlType, SingleValue};
impl<J, json, path_1, path_2, __Rhs> ::std::ops::Add<__Rhs> for
jsonb_remove_2<J, json, path_1, path_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, json, path_1, path_2, __Rhs> ::std::ops::Sub<__Rhs> for
jsonb_remove_2<J, json, path_1, path_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, json, path_1, path_2, __Rhs> ::std::ops::Mul<__Rhs> for
jsonb_remove_2<J, json, path_1, path_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, json, path_1, path_2, __Rhs> ::std::ops::Div<__Rhs> for
jsonb_remove_2<J, json, path_1, path_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, json: ::core::fmt::Debug,
path_1: ::core::fmt::Debug, path_2: ::core::fmt::Debug>
::core::fmt::Debug for jsonb_remove_2<J, json, path_1, path_2> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"jsonb_remove_2", "json", &self.json, "path_1", &self.path_1,
"path_2", &self.path_2, "J", &&self.J)
}
}
#[automatically_derived]
impl<J: ::core::clone::Clone, json: ::core::clone::Clone,
path_1: ::core::clone::Clone, path_2: ::core::clone::Clone>
::core::clone::Clone for jsonb_remove_2<J, json, path_1, path_2> {
#[inline]
fn clone(&self) -> jsonb_remove_2<J, json, path_1, path_2> {
jsonb_remove_2 {
json: ::core::clone::Clone::clone(&self.json),
path_1: ::core::clone::Clone::clone(&self.path_1),
path_2: ::core::clone::Clone::clone(&self.path_2),
J: ::core::clone::Clone::clone(&self.J),
}
}
}
#[automatically_derived]
impl<J: ::core::marker::Copy, json: ::core::marker::Copy,
path_1: ::core::marker::Copy, path_2: ::core::marker::Copy>
::core::marker::Copy for jsonb_remove_2<J, json, path_1, path_2> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<J: diesel::query_builder::QueryId,
json: diesel::query_builder::QueryId,
path_1: diesel::query_builder::QueryId,
path_2: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_remove_2<J, json, path_1, path_2> {
type QueryId =
jsonb_remove_2<<J as
diesel::query_builder::QueryId>::QueryId,
<json as diesel::query_builder::QueryId>::QueryId,
<path_1 as diesel::query_builder::QueryId>::QueryId,
<path_2 as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<J as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<json as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<path_1 as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<path_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 ||
<json as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<path_1 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<path_2 as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`jsonb_remove_2()`](fn@jsonb_remove_2)"]
pub type HelperType<J, json, path_1, path_2> =
jsonb_remove_2<J, <json as AsExpression<J>>::Expression,
<path_1 as AsExpression<Text>>::Expression,
<path_2 as AsExpression<Text>>::Expression>;
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2> Expression for jsonb_remove_2<J, json, path_1, path_2>
where (json, path_1, path_2): Expression {
type SqlType = Nullable<Jsonb>;
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_remove_2<J, json, path_1, path_2> where
json: SelectableExpression<__DieselInternal>,
path_1: SelectableExpression<__DieselInternal>,
path_2: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2, __DieselInternal> AppearsOnTable<__DieselInternal> for
jsonb_remove_2<J, json, path_1, path_2> where
json: AppearsOnTable<__DieselInternal>,
path_1: AppearsOnTable<__DieselInternal>,
path_2: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2, __DieselInternal> FunctionFragment<__DieselInternal>
for jsonb_remove_2<J, json, path_1, path_2> where
__DieselInternal: diesel::backend::Backend,
json: QueryFragment<__DieselInternal>,
path_1: QueryFragment<__DieselInternal>,
path_2: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_remove";
#[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.path_1.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.path_1.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.path_2.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.path_2.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2> QueryFragment<crate::sqlite::Sqlite> for
jsonb_remove_2<J, json, path_1, path_2> where
json: QueryFragment<crate::sqlite::Sqlite>,
path_1: QueryFragment<crate::sqlite::Sqlite>,
path_2: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<json, path_1, path_2>(json, path_1, path_2);
const _: () =
{
use diesel;
impl<json, path_1, path_2, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<json, path_1, path_2> where
json: diesel::expression::ValidGrouping<__GroupByClause>,
path_1: diesel::expression::ValidGrouping<__GroupByClause>,
path_2: diesel::expression::ValidGrouping<__GroupByClause>,
<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<path_1
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>,
<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<path_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output: diesel::expression::MixedAggregates<<path_2
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<<json as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<path_1 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
as
diesel::expression::MixedAggregates<<path_2 as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue, json,
path_1, path_2, __DieselInternal> ValidGrouping<__DieselInternal> for
jsonb_remove_2<J, json, path_1, path_2> where
__Derived<json, path_1, path_2>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<json, path_1, path_2> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[allow(unused_imports)]
#[doc(inline)]
mod __jsonb_remove_return_types {
#[doc(inline)]
pub use super::__jsonb_remove_0_return_type::*;
#[doc(inline)]
pub use super::__jsonb_remove_1_return_type::*;
#[doc(inline)]
pub use super::__jsonb_remove_2_return_type::*;
}
#[doc =
" Applies an RFC 7396 MergePatch `patch` to the input JSON `target` and"]
#[doc = " returns the patched JSON value."]
#[doc = ""]
#[doc =
" MergePatch can add, modify, or delete elements of a JSON object. Arrays are"]
#[doc =
" treated as atomic values: they can only be inserted, replaced, or deleted as a"]
#[doc = " whole, not modified element-wise."]
#[doc = ""]
#[doc = " # Examples"]
#[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_patch;"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Json, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = ""]
#[doc = " let result = diesel::select(json_patch::<Json, Json, _, _>("]
#[doc = " json!( {\"a\":1,\"b\":2} ),"]
#[doc = " json!( {\"c\":3,\"d\":4} ),"]
#[doc = " ))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!({\"a\":1,\"b\":2,\"c\":3,\"d\":4}), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_patch::<Json, Json, _, _>("]
#[doc = " json!( {\"a\":[1,2],\"b\":2} ),"]
#[doc = " json!( {\"a\":9} ),"]
#[doc = " ))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!({\"a\":9,\"b\":2}), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_patch::<Json, Json, _, _>("]
#[doc = " json!( {\"a\":[1,2],\"b\":2} ),"]
#[doc = " json!( {\"a\":null} ),"]
#[doc = " ))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!({\"b\":2}), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_patch::<Json, Json, _, _>("]
#[doc = " json!( {\"a\":1,\"b\":2} ),"]
#[doc = " json!( {\"a\":9,\"b\":null,\"c\":8} ),"]
#[doc = " ))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!({\"a\":9,\"c\":8}), result);"]
#[doc = ""]
#[doc = " let result = diesel::select(json_patch::<Json, Json, _, _>("]
#[doc = " json!( {\"a\":{\"x\":1,\"y\":2},\"b\":3} ),"]
#[doc = " json!( {\"a\":{\"y\":9},\"c\":8} ),"]
#[doc = " ))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!("]
#[doc = " json!({\"a\":{\"x\":1,\"y\":9},\"b\":3,\"c\":8}),"]
#[doc = " result"]
#[doc = " );"]
#[doc = ""]
#[doc = " // Nullable input yields nullable output"]
#[doc =
" let result = diesel::select(json_patch::<Nullable<Json>, Json, _, _>("]
#[doc = " None::<Value>,"]
#[doc = " json!({}),"]
#[doc = " ))"]
#[doc = " .get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn json_patch<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Json>, target,
patch>(target: target, patch: patch) -> json_patch<T, P, target, patch>
where target: diesel::expression::AsExpression<T>,
patch: diesel::expression::AsExpression<P> {
json_patch_utils::json_patch {
target: target.as_expression(),
patch: patch.as_expression(),
T: ::std::marker::PhantomData,
P: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`json_patch()`](fn@json_patch)"]
pub type json_patch<T, P, target, patch> =
json_patch_utils::json_patch<T, P,
<target as diesel::expression::AsExpression<T>>::Expression,
<patch as diesel::expression::AsExpression<P>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __json_patch_return_type {
#[doc =
"Return type of the [`json_patch()`](fn@super::json_patch) SQL function."]
pub type json_patch<target, patch> =
super::json_patch<<target as diesel::expression::Expression>::SqlType,
<patch as diesel::expression::Expression>::SqlType, target, patch>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod json_patch_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_patch<T, P, target, patch> {
pub(in super) target: target,
pub(in super) patch: patch,
pub(in super) T: ::std::marker::PhantomData<T>,
pub(in super) P: ::std::marker::PhantomData<P>,
}
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, P, target, patch, __Rhs> ::std::ops::Add<__Rhs> for
json_patch<T, P, target, patch> 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, P, target, patch, __Rhs> ::std::ops::Sub<__Rhs> for
json_patch<T, P, target, patch> 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, P, target, patch, __Rhs> ::std::ops::Mul<__Rhs> for
json_patch<T, P, target, patch> 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, P, target, patch, __Rhs> ::std::ops::Div<__Rhs> for
json_patch<T, P, target, patch> 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, P: ::core::fmt::Debug,
target: ::core::fmt::Debug, patch: ::core::fmt::Debug>
::core::fmt::Debug for json_patch<T, P, target, patch> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"json_patch", "target", &self.target, "patch", &self.patch,
"T", &self.T, "P", &&self.P)
}
}
#[automatically_derived]
impl<T: ::core::clone::Clone, P: ::core::clone::Clone,
target: ::core::clone::Clone, patch: ::core::clone::Clone>
::core::clone::Clone for json_patch<T, P, target, patch> {
#[inline]
fn clone(&self) -> json_patch<T, P, target, patch> {
json_patch {
target: ::core::clone::Clone::clone(&self.target),
patch: ::core::clone::Clone::clone(&self.patch),
T: ::core::clone::Clone::clone(&self.T),
P: ::core::clone::Clone::clone(&self.P),
}
}
}
#[automatically_derived]
impl<T: ::core::marker::Copy, P: ::core::marker::Copy,
target: ::core::marker::Copy, patch: ::core::marker::Copy>
::core::marker::Copy for json_patch<T, P, target, patch> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<T: diesel::query_builder::QueryId,
P: diesel::query_builder::QueryId,
target: diesel::query_builder::QueryId,
patch: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
json_patch<T, P, target, patch> {
type QueryId =
json_patch<<T as diesel::query_builder::QueryId>::QueryId,
<P as diesel::query_builder::QueryId>::QueryId,
<target as diesel::query_builder::QueryId>::QueryId,
<patch as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<P as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<target as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<patch as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<P as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<target as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<patch as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`json_patch()`](fn@json_patch)"]
pub type HelperType<T, P, target, patch> =
json_patch<T, P, <target as AsExpression<T>>::Expression,
<patch as AsExpression<P>>::Expression>;
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Json>, target, patch> Expression for
json_patch<T, P, target, patch> where (target, patch): Expression {
type SqlType = P::Out;
}
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Json>, target, patch, __DieselInternal>
SelectableExpression<__DieselInternal> for
json_patch<T, P, target, patch> where
target: SelectableExpression<__DieselInternal>,
patch: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Json>, target, patch, __DieselInternal>
AppearsOnTable<__DieselInternal> for json_patch<T, P, target, patch>
where target: AppearsOnTable<__DieselInternal>,
patch: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Json>, target, patch, __DieselInternal>
FunctionFragment<__DieselInternal> for json_patch<T, P, target, patch>
where __DieselInternal: diesel::backend::Backend,
target: QueryFragment<__DieselInternal>,
patch: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "json_patch";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.target.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.target.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.patch.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.patch.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Json>, target, patch>
QueryFragment<crate::sqlite::Sqlite> for
json_patch<T, P, target, patch> where
target: QueryFragment<crate::sqlite::Sqlite>,
patch: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<target, patch>(target, patch);
const _: () =
{
use diesel;
impl<target, patch, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<target, patch> where
target: diesel::expression::ValidGrouping<__GroupByClause>,
patch: diesel::expression::ValidGrouping<__GroupByClause>,
<target as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<patch
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<target as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<patch as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Json>, target, patch, __DieselInternal>
ValidGrouping<__DieselInternal> for json_patch<T, P, target, patch>
where __Derived<target, patch>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<target, patch> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[doc =
" Applies an RFC 7396 MergePatch `patch` to the input JSON `target` and"]
#[doc = " returns the patched JSON value in SQLite\'s binary JSONB format."]
#[doc = ""]
#[doc =
" See [`json_patch`](json_patch()) for details about the MergePatch semantics."]
#[doc = ""]
#[doc = " # Examples"]
#[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_patch;"]
#[doc = " # use serde_json::{json, Value};"]
#[doc = " # use diesel::sql_types::{Jsonb, Nullable};"]
#[doc = " # let connection = &mut establish_connection();"]
#[doc = " # assert_version!(connection, 3, 45, 0);"]
#[doc = ""]
#[doc = " let result = diesel::select(jsonb_patch::<Jsonb, Jsonb, _, _>("]
#[doc = " json!( {\"a\":1,\"b\":2} ),"]
#[doc = " json!( {\"c\":3,\"d\":4} ),"]
#[doc = " ))"]
#[doc = " .get_result::<Value>(connection)?;"]
#[doc = " assert_eq!(json!({\"a\":1,\"b\":2,\"c\":3,\"d\":4}), result);"]
#[doc = ""]
#[doc = " // Nullable input yields nullable output"]
#[doc =
" let result = diesel::select(jsonb_patch::<Nullable<Jsonb>, Jsonb, _, _>("]
#[doc = " None::<Value>,"]
#[doc = " json!({}),"]
#[doc = " ))"]
#[doc = " .get_result::<Option<Value>>(connection)?;"]
#[doc = " assert!(result.is_none());"]
#[doc = ""]
#[doc = " # Ok(())"]
#[doc = " # }"]
#[doc = " ```"]
#[allow(non_camel_case_types)]
pub fn jsonb_patch<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Jsonb>, target,
patch>(target: target, patch: patch) -> jsonb_patch<T, P, target, patch>
where target: diesel::expression::AsExpression<T>,
patch: diesel::expression::AsExpression<P> {
jsonb_patch_utils::jsonb_patch {
target: target.as_expression(),
patch: patch.as_expression(),
T: ::std::marker::PhantomData,
P: ::std::marker::PhantomData,
}
}
#[allow(non_camel_case_types, non_snake_case)]
#[doc = "The return type of [`jsonb_patch()`](fn@jsonb_patch)"]
pub type jsonb_patch<T, P, target, patch> =
jsonb_patch_utils::jsonb_patch<T, P,
<target as diesel::expression::AsExpression<T>>::Expression,
<patch as diesel::expression::AsExpression<P>>::Expression>;
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
#[doc(inline)]
mod __jsonb_patch_return_type {
#[doc =
"Return type of the [`jsonb_patch()`](fn@super::jsonb_patch) SQL function."]
pub type jsonb_patch<target, patch> =
super::jsonb_patch<<target as
diesel::expression::Expression>::SqlType,
<patch as diesel::expression::Expression>::SqlType, target, patch>;
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod jsonb_patch_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_patch<T, P, target, patch> {
pub(in super) target: target,
pub(in super) patch: patch,
pub(in super) T: ::std::marker::PhantomData<T>,
pub(in super) P: ::std::marker::PhantomData<P>,
}
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, P, target, patch, __Rhs> ::std::ops::Add<__Rhs> for
jsonb_patch<T, P, target, patch> 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, P, target, patch, __Rhs> ::std::ops::Sub<__Rhs> for
jsonb_patch<T, P, target, patch> 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, P, target, patch, __Rhs> ::std::ops::Mul<__Rhs> for
jsonb_patch<T, P, target, patch> 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, P, target, patch, __Rhs> ::std::ops::Div<__Rhs> for
jsonb_patch<T, P, target, patch> 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, P: ::core::fmt::Debug,
target: ::core::fmt::Debug, patch: ::core::fmt::Debug>
::core::fmt::Debug for jsonb_patch<T, P, target, patch> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"jsonb_patch", "target", &self.target, "patch", &self.patch,
"T", &self.T, "P", &&self.P)
}
}
#[automatically_derived]
impl<T: ::core::clone::Clone, P: ::core::clone::Clone,
target: ::core::clone::Clone, patch: ::core::clone::Clone>
::core::clone::Clone for jsonb_patch<T, P, target, patch> {
#[inline]
fn clone(&self) -> jsonb_patch<T, P, target, patch> {
jsonb_patch {
target: ::core::clone::Clone::clone(&self.target),
patch: ::core::clone::Clone::clone(&self.patch),
T: ::core::clone::Clone::clone(&self.T),
P: ::core::clone::Clone::clone(&self.P),
}
}
}
#[automatically_derived]
impl<T: ::core::marker::Copy, P: ::core::marker::Copy,
target: ::core::marker::Copy, patch: ::core::marker::Copy>
::core::marker::Copy for jsonb_patch<T, P, target, patch> {
}
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<T: diesel::query_builder::QueryId,
P: diesel::query_builder::QueryId,
target: diesel::query_builder::QueryId,
patch: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
jsonb_patch<T, P, target, patch> {
type QueryId =
jsonb_patch<<T as diesel::query_builder::QueryId>::QueryId,
<P as diesel::query_builder::QueryId>::QueryId,
<target as diesel::query_builder::QueryId>::QueryId,
<patch as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<T as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<P as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<target as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<patch as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<T as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<P as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<target as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<patch as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};
#[doc = "The return type of [`jsonb_patch()`](fn@jsonb_patch)"]
pub type HelperType<T, P, target, patch> =
jsonb_patch<T, P, <target as AsExpression<T>>::Expression,
<patch as AsExpression<P>>::Expression>;
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Jsonb>, target, patch> Expression for
jsonb_patch<T, P, target, patch> where (target, patch): Expression {
type SqlType = P::Out;
}
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Jsonb>, target, patch, __DieselInternal>
SelectableExpression<__DieselInternal> for
jsonb_patch<T, P, target, patch> where
target: SelectableExpression<__DieselInternal>,
patch: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal> {}
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Jsonb>, target, patch, __DieselInternal>
AppearsOnTable<__DieselInternal> for jsonb_patch<T, P, target, patch>
where target: AppearsOnTable<__DieselInternal>,
patch: AppearsOnTable<__DieselInternal>, Self: Expression {}
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Jsonb>, target, patch, __DieselInternal>
FunctionFragment<__DieselInternal> for
jsonb_patch<T, P, target, patch> where
__DieselInternal: diesel::backend::Backend,
target: QueryFragment<__DieselInternal>,
patch: QueryFragment<__DieselInternal> {
const FUNCTION_NAME: &'static str = "jsonb_patch";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>) -> QueryResult<()> {
let mut needs_comma = false;
if !self.target.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.target.walk_ast(out.reborrow())?;
needs_comma = true;
}
if !self.patch.is_noop(out.backend())? {
if needs_comma { out.push_sql(", "); }
self.patch.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Jsonb>, target, patch>
QueryFragment<crate::sqlite::Sqlite> for
jsonb_patch<T, P, target, patch> where
target: QueryFragment<crate::sqlite::Sqlite>,
patch: QueryFragment<crate::sqlite::Sqlite> {
fn walk_ast<'__b>(&'__b self,
mut out: AstPass<'_, '__b, crate::sqlite::Sqlite>)
-> QueryResult<()> {
out.push_sql(<Self as
FunctionFragment<crate::sqlite::Sqlite>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
pub struct __Derived<target, patch>(target, patch);
const _: () =
{
use diesel;
impl<target, patch, __GroupByClause>
diesel::expression::ValidGrouping<__GroupByClause> for
__Derived<target, patch> where
target: diesel::expression::ValidGrouping<__GroupByClause>,
patch: diesel::expression::ValidGrouping<__GroupByClause>,
<target as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate: diesel::expression::MixedAggregates<<patch
as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>
{
type IsAggregate =
<<target as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate
as
diesel::expression::MixedAggregates<<patch as
diesel::expression::ValidGrouping<__GroupByClause>>::IsAggregate>>::Output;
}
};
impl<T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue +
CombinedNullableValue<T, Jsonb>, target, patch, __DieselInternal>
ValidGrouping<__DieselInternal> for jsonb_patch<T, P, target, patch>
where __Derived<target, patch>: ValidGrouping<__DieselInternal> {
type IsAggregate =
<__Derived<target, patch> as
ValidGrouping<__DieselInternal>>::IsAggregate;
}
}
#[allow(unused_imports)]
#[doc(hidden)]
mod return_type_helpers {
#[doc(inline)]
pub use super::__json_return_type::*;
#[doc(inline)]
pub use super::__jsonb_return_type::*;
#[doc(inline)]
pub use super::__json_array_length_return_type::*;
#[doc(inline)]
pub use super::__json_array_length_with_path_return_type::*;
#[doc(inline)]
pub use super::__json_error_position_return_type::*;
#[doc(inline)]
pub use super::__json_pretty_return_type::*;
#[doc(inline)]
pub use super::__json_pretty_with_indentation_return_type::*;
#[doc(inline)]
pub use super::__json_valid_return_type::*;
#[doc(inline)]
pub use super::__json_type_return_type::*;
#[doc(inline)]
pub use super::__json_type_with_path_return_type::*;
#[doc(inline)]
pub use super::__json_quote_return_type::*;
#[doc(inline)]
pub use super::__json_group_array_return_type::*;
#[doc(inline)]
pub use super::__jsonb_group_array_return_type::*;
#[doc(inline)]
pub use super::__json_group_object_return_type::*;
#[doc(inline)]
pub use super::__jsonb_group_object_return_type::*;
#[doc(inline)]
pub use super::__json_array_return_types::*;
#[doc(inline)]
pub use super::__jsonb_array_return_types::*;
#[doc(inline)]
pub use super::__json_remove_return_types::*;
#[doc(inline)]
pub use super::__jsonb_remove_return_types::*;
#[doc(inline)]
pub use super::__json_patch_return_type::*;
#[doc(inline)]
pub use super::__jsonb_patch_return_type::*;
}#[declare_sql_function(generate_return_type_helpers = true)]
17#[backends(crate::sqlite::Sqlite)]
18extern "SQL" {
19 fn json<E: TextOrNullableText + MaybeNullableValue<Json>>(e: E) -> E::Out;
58
59 fn jsonb<E: BinaryOrNullableBinary + MaybeNullableValue<Jsonb>>(e: E) -> E::Out;
100
101 #[cfg(feature = "sqlite")]
159 fn json_array_length<
160 J: JsonOrNullableJsonOrJsonbOrNullableJsonb + MaybeNullableValue<Integer>,
161 >(
162 j: J,
163 ) -> J::Out;
164
165 #[sql_name = "json_array_length"]
236 #[cfg(feature = "sqlite")]
237 fn json_array_length_with_path<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue>(
238 j: J,
239 path: Text,
240 ) -> Nullable<Integer>;
241
242 #[cfg(feature = "sqlite")]
330 fn json_error_position<
331 X: TextOrNullableTextOrBinaryOrNullableBinary + MaybeNullableValue<Integer>,
332 >(
333 x: X,
334 ) -> X::Out;
335
336 fn json_pretty<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + MaybeNullableValue<Text>>(
463 j: J,
464 ) -> J::Out;
465
466 #[sql_name = "json_pretty"]
620 fn json_pretty_with_indentation<
621 J: JsonOrNullableJsonOrJsonbOrNullableJsonb + MaybeNullableValue<Text>,
622 >(
623 j: J,
624 indentation: Nullable<Text>,
625 ) -> J::Out;
626
627 #[sql_name = "json_valid"]
663 #[cfg(feature = "sqlite")]
664 fn json_valid<J: JsonOrNullableJson + MaybeNullableValue<Bool>>(j: J) -> J::Out;
665
666 #[sql_name = "json_type"]
709 #[cfg(feature = "sqlite")]
710 fn json_type<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + MaybeNullableValue<Text>>(
711 j: J,
712 ) -> J::Out;
713
714 #[sql_name = "json_type"]
778 #[cfg(feature = "sqlite")]
779 fn json_type_with_path<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue>(
780 j: J,
781 path: Text,
782 ) -> Nullable<Text>;
783
784 #[sql_name = "json_quote"]
836 #[cfg(feature = "sqlite")]
837 fn json_quote<J: SqlType + SingleValue>(j: J) -> Json;
838
839 #[cfg(feature = "sqlite")]
915 #[aggregate]
916 fn json_group_array<E: SqlType + SingleValue>(elements: E) -> Json;
917
918 #[cfg(feature = "sqlite")]
995 #[aggregate]
996 fn jsonb_group_array<E: SqlType + SingleValue>(elements: E) -> Jsonb;
997
998 #[cfg(feature = "sqlite")]
1082 #[aggregate]
1083 fn json_group_object<
1084 N: SqlType<IsNull = is_nullable::NotNull> + SingleValue,
1085 V: SqlType + SingleValue,
1086 >(
1087 names: N,
1088 values: V,
1089 ) -> Json;
1090
1091 #[cfg(feature = "sqlite")]
1175 #[aggregate]
1176 fn jsonb_group_object<
1177 N: SqlType<IsNull = is_nullable::NotNull> + SingleValue,
1178 V: SqlType + SingleValue,
1179 >(
1180 names: N,
1181 values: V,
1182 ) -> Jsonb;
1183
1184 #[cfg(feature = "sqlite")]
1229 #[variadic(1)]
1230 fn json_array<V: NotBlob>(value: V) -> Json;
1231
1232 #[cfg(feature = "sqlite")]
1281 #[variadic(1)]
1282 fn jsonb_array<V: NotBlob>(value: V) -> Jsonb;
1283
1284 #[cfg(feature = "sqlite")]
1350 #[variadic(1)]
1351 fn json_remove<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue>(
1352 json: J,
1353 path: Text,
1354 ) -> Nullable<Json>;
1355
1356 #[cfg(feature = "sqlite")]
1424 #[variadic(1)]
1425 fn jsonb_remove<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue>(
1426 json: J,
1427 path: Text,
1428 ) -> Nullable<Jsonb>;
1429
1430 #[cfg(feature = "sqlite")]
1504 fn json_patch<
1505 T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
1506 P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue + CombinedNullableValue<T, Json>,
1507 >(
1508 target: T,
1509 patch: P,
1510 ) -> P::Out;
1511
1512 #[cfg(feature = "sqlite")]
1554 fn jsonb_patch<
1555 T: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue,
1556 P: JsonOrNullableJsonOrJsonbOrNullableJsonb + SingleValue + CombinedNullableValue<T, Jsonb>,
1557 >(
1558 target: T,
1559 patch: P,
1560 ) -> P::Out;
1561}
1562
1563pub(super) mod return_type_helpers_reexported {
1564 #[allow(unused_imports)]
1565 #[doc(inline)]
1566 pub use super::return_type_helpers::*;
1567}