diesel::pg::expression::dsl

Function isempty

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

Returns true if the range is empty

ยงExample

let int = diesel::select(isempty::<Range<Integer>,  _>(1..5)).get_result::<bool>(connection)?;
assert_eq!(false, int);

let int = diesel::select(isempty::<Range<Integer>, _>(1..1)).get_result::<bool>(connection)?;
assert_eq!(true, int);

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

let int = diesel::select(isempty::<Multirange<Integer>, _>(vec![5..7])).get_result::<bool>(connection)?;
assert_eq!(false, int);