Skip to content

Commit

Permalink
Merge pull request #4324 from meeshal/add_missing_json_expressions
Browse files Browse the repository at this point in the history
add support for json expression methods
  • Loading branch information
weiznich authored Nov 17, 2024
2 parents 27421b9 + a271e60 commit 5a2940e
Show file tree
Hide file tree
Showing 5 changed files with 432 additions and 80 deletions.
74 changes: 74 additions & 0 deletions diesel/src/expression/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,80 @@ macro_rules! postfix_operator {
$crate::postfix_operator!($name, $operator, $crate::sql_types::Bool, backend: $backend);
};

($name:ident, $operator:expr, ConditionalNullability $($return_ty:tt)::*) => {
$crate::postfix_operator!(
name = $name,
operator = $operator,
return_ty = NullableBasedOnArgs ($($return_ty)::*),
);
};

($name:ident, $operator:expr, ConditionalNullability $($return_ty:tt)::*, backend: $backend:ty) => {
$crate::postfix_operator!(
$name,
$operator,
return_ty = NullableBasedOnArgs ($($return_ty)::*),
backend: $backend
);
};

($name:ident, $operator:expr, return_ty = NullableBasedOnArgs($return_ty:ty)) => {
$crate::__diesel_operator_body!(
notation = postfix,
struct_name = $name,
operator = $operator,
return_ty = (
$crate::sql_types::is_nullable::MaybeNullable<
<<Expr as $crate::expression::Expression>::SqlType as $crate::sql_types::SqlType>::IsNull,
$return_ty
>
),
ty_params = (Expr,),
field_names = (expr,),
backend_ty_params = (DB,),
backend_ty = DB,
expression_ty_params = (),
expression_bounds = (
Expr: $crate::expression::Expression,
<Expr as $crate::expression::Expression>::SqlType: $crate::sql_types::SqlType,
$crate::sql_types::is_nullable::IsOneNullable<
<Expr as $crate::expression::Expression>::SqlType,
$return_ty
>: $crate::sql_types::MaybeNullableType<$return_ty>,
),
);
};

($name:ident, $operator:expr, return_ty = NullableBasedOnArgs($return_ty:ty), backend: $backend:ty) => {
$crate::__diesel_operator_body!(
notation = postfix,
struct_name = $name,
operator = $operator,
return_ty = (
$crate::sql_types::is_nullable::MaybeNullable<
$crate::sql_types::is_nullable::IsOneNullable<
<Expr as $crate::expression::Expression>::SqlType,
$return_ty
>,
$return_ty
>
),
ty_params = (Expr,),
field_names = (expr,),
backend_ty_params = (),
backend_ty = $backend,
expression_ty_params = (),
expression_bounds = (
Expr: $crate::expression::Expression,
<Expr as $crate::expression::Expression>::SqlType: $crate::sql_types::SqlType,
$crate::sql_types::is_nullable::IsOneNullable<
<Expr as $crate::expression::Expression>::SqlType,
$return_ty
>: $crate::sql_types::MaybeNullableType<$return_ty>,
),
);
};

($name:ident, $operator:expr, $return_ty:ty) => {
$crate::__diesel_operator_body!(
notation = postfix,
Expand Down
Loading

0 comments on commit 5a2940e

Please sign in to comment.