Function quaint::ast::coalesce

source ·
pub fn coalesce<'a, T, V>(exprs: V) -> Function<'a>where
    T: Into<Expression<'a>>,
    V: Into<Vec<T>>,
Expand description

Returns the first non-null argument

let exprs: Vec<Expression> = vec![
  Column::from(("users", "company")).into(),
  Value::text("Individual").into(),
];
let query = Select::from_table("users").value(coalesce(exprs));
let (sql, params) = Sqlite::build(query)?;
assert_eq!("SELECT COALESCE(`users`.`company`, ?) FROM `users`", sql);
assert_eq!(vec![Value::text("Individual")], params);