Skip to content

Commit

Permalink
feat(sqlite): update return type of json_error_position
Browse files Browse the repository at this point in the history
  • Loading branch information
IamTossan authored and weiznich committed Mar 4, 2025
1 parent 0631d0d commit 0f8b58f
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions diesel/src/sqlite/expression/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,14 @@ extern "SQL" {
/// }
///
/// let result = diesel::select(json_error_position::<Text, _>(r#"{"a": "b", "c": 1}"#))
/// .get_result::<Option<i32>>(connection)?;
/// .get_result::<i32>(connection)?;
///
/// assert_eq!(Some(0), result);
/// assert_eq!(0, result);
///
/// let result = diesel::select(json_error_position::<Text, _>(r#"{"a": b", "c": 1}"#))
/// .get_result::<Option<i32>>(connection)?;
/// .get_result::<i32>(connection)?;
///
/// assert_eq!(Some(7), result);
/// assert_eq!(7, result);
///
/// let json5 = r#"
/// {
Expand All @@ -332,9 +332,9 @@ extern "SQL" {
/// }
/// "#;
/// let result = diesel::select(json_error_position::<Text, _>(json5))
/// .get_result::<Option<i32>>(connection)?;
/// .get_result::<i32>(connection)?;
///
/// assert_eq!(Some(0), result);
/// assert_eq!(0, result);
///
/// let json5_with_error = r#"
/// {
Expand All @@ -346,24 +346,24 @@ extern "SQL" {
/// }
/// "#;
/// let result = diesel::select(json_error_position::<Text, _>(json5_with_error))
/// .get_result::<Option<i32>>(connection)?;
/// .get_result::<i32>(connection)?;
///
/// assert_eq!(Some(59), result);
/// assert_eq!(59, result);
///
/// let result = diesel::select(json_error_position::<Nullable<Text>, _>(None::<&str>))
/// .get_result::<Option<i32>>(connection)?;
///
/// assert_eq!(None, result);
///
/// let result = diesel::select(json_error_position::<Binary, _>(br#"{"a": "b", "c": 1}"#))
/// .get_result::<Option<i32>>(connection)?;
/// .get_result::<i32>(connection)?;
///
/// assert_eq!(Some(0), result);
/// assert_eq!(0, result);
///
/// let result = diesel::select(json_error_position::<Binary, _>(br#"{"a": b", "c": 1}"#))
/// .get_result::<Option<i32>>(connection)?;
/// .get_result::<i32>(connection)?;
///
/// assert_eq!(Some(7), result);
/// assert_eq!(7, result);
///
/// let result = diesel::select(json_error_position::<Nullable<Binary>, _>(None::<Vec<u8>>))
/// .get_result::<Option<i32>>(connection)?;
Expand All @@ -374,9 +374,11 @@ extern "SQL" {
/// # }
/// ```
#[cfg(feature = "sqlite")]
fn json_error_position<X: TextOrNullableTextOrBinaryOrNullableBinary + SingleValue>(
fn json_error_position<
X: TextOrNullableTextOrBinaryOrNullableBinary + MaybeNullableValue<Integer>,
>(
x: X,
) -> Nullable<Integer>;
) -> X::Out;

/// Converts the given json value to pretty-printed, indented text
///
Expand Down

0 comments on commit 0f8b58f

Please sign in to comment.