pub trait PgRangeExpressionMethods: Expression + Sized {
// Provided method
fn contains<T>(self, other: T) -> RangeContains<Self, T>
where Self::SqlType: RangeHelper,
<Self::SqlType as RangeHelper>::Inner: SqlType + TypedExpressionType,
T: AsExpression<<Self::SqlType as RangeHelper>::Inner> { ... }
}
Expand description
PostgreSQL specific methods present on range expressions.
Provided Methods§
sourcefn contains<T>(self, other: T) -> RangeContains<Self, T>where
Self::SqlType: RangeHelper,
<Self::SqlType as RangeHelper>::Inner: SqlType + TypedExpressionType,
T: AsExpression<<Self::SqlType as RangeHelper>::Inner>,
fn contains<T>(self, other: T) -> RangeContains<Self, T>where Self::SqlType: RangeHelper, <Self::SqlType as RangeHelper>::Inner: SqlType + TypedExpressionType, T: AsExpression<<Self::SqlType as RangeHelper>::Inner>,
Creates a PostgreSQL @>
expression.
This operator returns whether a range contains an specific element
Example
diesel::insert_into(posts)
.values(versions.eq((Bound::Included(5), Bound::Unbounded)))
.execute(conn)?;
let cool_posts = posts.select(id)
.filter(versions.contains(42))
.load::<i32>(conn)?;
assert_eq!(vec![1], cool_posts);
let amazing_posts = posts.select(id)
.filter(versions.contains(1))
.load::<i32>(conn)?;
assert!(amazing_posts.is_empty());