Trait diesel::expression_methods::PgExpressionMethods [−][src]
pub trait PgExpressionMethods: Expression + Sized {
fn is_not_distinct_from<T>(
self,
other: T
) -> IsNotDistinctFrom<Self, T::Expression>
where
T: AsExpression<Self::SqlType>,
{ ... }
fn is_distinct_from<T>(
self,
other: T
) -> IsDistinctFrom<Self, T::Expression>
where
T: AsExpression<Self::SqlType>,
{ ... }
}
Expand description
PostgreSQL specific methods which are present on all expressions.
Provided methods
fn is_not_distinct_from<T>(
self,
other: T
) -> IsNotDistinctFrom<Self, T::Expression> where
T: AsExpression<Self::SqlType>,
fn is_not_distinct_from<T>(
self,
other: T
) -> IsNotDistinctFrom<Self, T::Expression> where
T: AsExpression<Self::SqlType>,
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));
fn is_distinct_from<T>(self, other: T) -> IsDistinctFrom<Self, T::Expression> where
T: AsExpression<Self::SqlType>,
fn is_distinct_from<T>(self, other: T) -> IsDistinctFrom<Self, T::Expression> where
T: AsExpression<Self::SqlType>,
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));