pub fn int4range<lower, upper, bound>(
lower: lower,
upper: upper,
bound: bound,
) -> int4range<lower, upper, bound>where
lower: AsExpression<Nullable<Integer>>,
upper: AsExpression<Nullable<Integer>>,
bound: AsExpression<RangeBoundEnum>,
Available on crate feature
postgres_backend
only.Expand description
Returns range of integer
ยงExample
use diesel::dsl::int4range;
use diesel::pg::sql_types::RangeBound;
diesel::insert_into(posts)
.values(&[
versions.eq(int4range(Some(3), Some(5), RangeBound::LowerBoundInclusiveUpperBoundInclusive)),
versions.eq(int4range(None, Some(2), RangeBound::LowerBoundInclusiveUpperBoundExclusive)),
]).execute(conn)?;
let cool_posts = posts.select(versions)
.load::<(Bound<i32>, Bound<i32>)>(conn)?;
assert_eq!(vec![
(Bound::Included(3), Bound::Excluded(6)), // Postgres cast this internally
(Bound::Unbounded, Bound::Excluded(2)),
], cool_posts);