diesel::pg::expression::dsl

Function int8range

source
pub fn int8range<lower, upper, bound>(
    lower: lower,
    upper: upper,
    bound: bound,
) -> int8range<lower, upper, bound>
Available on crate feature postgres_backend only.
Expand description

Returns range of big ints

ยงExample

use diesel::dsl::int8range;
use diesel::pg::sql_types::RangeBound;

diesel::insert_into(posts)
    .values(&[
       versions.eq(int8range(Some(3), Some(5), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),
       versions.eq(int8range(None, Some(2), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),
    ]).execute(conn)?;

let cool_posts = posts.select(versions)
    .load::<(Bound<i64>, Bound<i64>)>(conn)?;
assert_eq!(vec![
         (Bound::Included(3), Bound::Excluded(6)), // Postgres cast this internally
         (Bound::Unbounded, Bound::Excluded(2)),
     ], cool_posts);