diesel::pg::expression::dsl

Function upper

source
pub fn upper<R: MultirangeOrRangeMaybeNullable + SingleValue, range>(
    range: range,
) -> upper<R, range>
where range: AsExpression<R>,
Available on crate feature postgres_backend only.
Expand description

Returns the upper bound of the range

If the range is empty or has no upper bound, it returns NULL.

ยงExample

let int = diesel::select(upper::<Range<_>,  _>(1..2)).get_result::<Option<i32>>(connection)?;
assert_eq!(Some(2), int);

let int = diesel::select(upper::<Range<_>, _>(1..)).get_result::<Option<i32>>(connection)?;
assert_eq!(None, int);

let int = diesel::select(upper::<Nullable<Range<_>>, _>(None::<std::ops::Range<i32>>)).get_result::<Option<i32>>(connection)?;
assert_eq!(None, int);

let int = diesel::select(upper::<Multirange<_>, _>(vec![5..7])).get_result::<Option<i32>>(connection)?;
assert_eq!(Some(7), int);