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