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: AsExpression<T>,
patch: AsExpression<P>,
Expand description
Applies an RFC 7396 MergePatch patch
to the input JSON target
and
returns the patched JSON value in SQLite’s binary JSONB format.
See json_patch
for details about the MergePatch semantics.
§Examples
let result = diesel::select(jsonb_patch::<Jsonb, Jsonb, _, _>(
json!( {"a":1,"b":2} ),
json!( {"c":3,"d":4} ),
))
.get_result::<Value>(connection)?;
assert_eq!(json!({"a":1,"b":2,"c":3,"d":4}), result);
// Nullable input yields nullable output
let result = diesel::select(jsonb_patch::<Nullable<Jsonb>, Jsonb, _, _>(
None::<Value>,
json!({}),
))
.get_result::<Option<Value>>(connection)?;
assert!(result.is_none());