pub fn ifnull<'a, V, E, D>(
expr: E,
default: D,
) -> SQLExpr<'a, V, E::SQLType, <E::Nullable as Nullability>::And<D::Nullable>, <E::Aggregate as AggregateKind>::Or<D::Aggregate>, Coalesce<Arg<<E as Expr<'a, V>>::Nullable, <E as ExprSources>::Sources>, Arg<<D as Expr<'a, V>>::Nullable, <D as ExprSources>::Sources>>>where
V: SQLParam + 'a,
E: Expr<'a, V>,
D: Expr<'a, V>,
E::SQLType: Compatible<D::SQLType>,
D::Nullable: Nullability,
D::Aggregate: AggregateKind,Expand description
The first value, or default when it is NULL (IFNULL(expr, default)).
Same typing as coalesce. IFNULL exists on SQLite and MySQL but not on
PostgreSQL. This function is not restricted by dialect, so on PostgreSQL
it compiles but the database rejects it; use coalesce there.
ยงExamples
let email = ifnull(users.email, "unknown");
assert_eq!(email.sql(), r#"IFNULL ("users"."email", ?)"#);