Macro quaint::col

source ·
macro_rules! col {
    ($e1:expr) => { ... };
    ($e1:expr, $e2:expr) => { ... };
}
Expand description

Marks a given string or a tuple as a column. Useful when using a column in calculations, e.g.

let join = "dogs".on(("dogs", "slave_id").equals(Column::from(("cats", "master_id"))));

let query = Select::from_table("cats")
    .value(Table::from("cats").asterisk())
    .value(col!("dogs", "age") - val!(4))
    .inner_join(join);

let (sql, params) = Sqlite::build(query)?;

assert_eq!(
    "SELECT `cats`.*, (`dogs`.`age` - ?) FROM `cats` INNER JOIN `dogs` ON `dogs`.`slave_id` = `cats`.`master_id`",
    sql
);