pub trait PgExpressionMethods: Sized + Expression {
// Provided methods
fn is_not_distinct_from<T>(
self,
other: T,
) -> Grouped<IsNotDistinctFrom<Self, <T as AsExpression<Self::SqlType>>::Expression>>
where Self::SqlType: SqlType,
T: AsExpression<Self::SqlType> { ... }
fn is_distinct_from<T>(
self,
other: T,
) -> Grouped<IsDistinctFrom<Self, <T as AsExpression<Self::SqlType>>::Expression>>
where Self::SqlType: SqlType,
T: AsExpression<Self::SqlType> { ... }
fn is_contained_by_range<T>(
self,
other: T,
) -> Grouped<IsContainedBy<Self, <T as AsExpression<Range<Self::SqlType>>>::Expression>>
where Self::SqlType: SqlType,
T: AsExpression<Range<Self::SqlType>> { ... }
}Expand description
PostgreSQL specific methods which are present on all expressions.
Provided Methods§
Sourcefn is_not_distinct_from<T>(
self,
other: T,
) -> Grouped<IsNotDistinctFrom<Self, <T as AsExpression<Self::SqlType>>::Expression>>
fn is_not_distinct_from<T>( self, other: T, ) -> Grouped<IsNotDistinctFrom<Self, <T as AsExpression<Self::SqlType>>::Expression>>
Creates a PostgreSQL IS NOT DISTINCT FROM expression.
This behaves identically to the = operator, except that NULL is
treated as a normal value.
§Example
let distinct = users.select(id).filter(name.is_distinct_from("Sean"));
let not_distinct = users.select(id).filter(name.is_not_distinct_from("Sean"));
assert_eq!(Ok(2), distinct.first(connection));
assert_eq!(Ok(1), not_distinct.first(connection));Sourcefn is_distinct_from<T>(
self,
other: T,
) -> Grouped<IsDistinctFrom<Self, <T as AsExpression<Self::SqlType>>::Expression>>
fn is_distinct_from<T>( self, other: T, ) -> Grouped<IsDistinctFrom<Self, <T as AsExpression<Self::SqlType>>::Expression>>
Creates a PostgreSQL IS DISTINCT FROM expression.
This behaves identically to the != operator, except that NULL is
treated as a normal value.
§Example
let distinct = users.select(id).filter(name.is_distinct_from("Sean"));
let not_distinct = users.select(id).filter(name.is_not_distinct_from("Sean"));
assert_eq!(Ok(2), distinct.first(connection));
assert_eq!(Ok(1), not_distinct.first(connection));Sourcefn is_contained_by_range<T>(
self,
other: T,
) -> Grouped<IsContainedBy<Self, <T as AsExpression<Range<Self::SqlType>>>::Expression>>
fn is_contained_by_range<T>( self, other: T, ) -> Grouped<IsContainedBy<Self, <T as AsExpression<Range<Self::SqlType>>>::Expression>>
Creates a PostgreSQL <@ expression.
This operator returns true whether a element is contained by a range
This operator evaluates to true for the following cases:
self: |
other: [-----]self: |
other: [----]self: |
other: [----]This operator evaluates to false for the following cases:
self: |
other: [-----]self: |
other: [----]self: |
other: [----)§Example
let my_range = int4range(
1,
5,
diesel::sql_types::RangeBound::LowerBoundInclusiveUpperBoundExclusive,
);
let (first, second) = diesel::select((
4.into_sql::<Integer>().is_contained_by_range(my_range),
10.into_sql::<Integer>().is_contained_by_range(my_range),
))
.get_result::<(bool, bool)>(conn)?;
assert_eq!(first, true);
assert_eq!(second, false);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.