rocket_db_pools::diesel::prelude

Trait PgRangeExpressionMethods

Source
pub trait PgRangeExpressionMethods: Sized + Expression {
    // Provided method
    fn contains<T>(
        self,
        other: T,
    ) -> Grouped<Contains<Self, <T as AsExpression<<Self::SqlType as RangeHelper>::Inner>>::Expression>>
       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§

Source

fn contains<T>( self, other: T, ) -> Grouped<Contains<Self, <T as AsExpression<<Self::SqlType as RangeHelper>::Inner>>::Expression>>
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.

Implementors§

Source§

impl<T> PgRangeExpressionMethods for T
where T: Expression, <T as Expression>::SqlType: RangeOrNullableRange,