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> { ... }
}
Available on crate feature
postgres_backend
only.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());
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.