diesel::pg::expression::dsl

Function array_upper

Source
pub fn array_upper<Arr: ArrayOrNullableArray + SingleValue, array, dimension>(
    array: array,
    dimension: dimension,
) -> array_upper<Arr, array, dimension>
where array: AsExpression<Arr>, dimension: AsExpression<Integer>,
Available on crate feature postgres_backend only.
Expand description

Returns the upper bound of the requested array

This function returns null for dimensions that do not exist

ยงExample

let result = diesel::select(array_upper::<Array<Integer>, _, _>(vec![1, 2, 3], 1))
    .get_result::<Option<i32>>(connection)?;
assert_eq!(Some(3), result);

// the array has only one dimension
let result = diesel::select(array_upper::<Array<Integer>, _, _>(vec![1, 2, 3], 2))
    .get_result::<Option<i32>>(connection)?;
assert_eq!(None, result);