diesel::pg::expression::dsl

Function lower

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

Returns the lower bound of the range

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

ยงExample

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

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

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

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