Skip to main content

nullif

Function nullif 

Source
pub fn nullif<'a, V, E1, E2>(
    expr1: E1,
    expr2: E2,
) -> SQLExpr<'a, V, E1::SQLType, Null, <E1::Aggregate as AggOr<E2::Aggregate>>::Output>
where V: SQLParam + 'a, E1: Expr<'a, V>, E2: Expr<'a, V>, E1::SQLType: Compatible<E2::SQLType>, E1::Aggregate: AggOr<E2::Aggregate>, E2::Aggregate: AggregateKind,
Expand description

NULLIF - returns NULL if arguments are equal, else first argument.

Requires compatible types between the two arguments. The result is always nullable since it can return NULL.

ยงExample

use drizzle_core::expr::nullif;

// Returns NULL if status is 'unknown', otherwise returns status
let status = nullif(item.status, "unknown");