Macro fire_postgres::filter
source · macro_rules! filter { (cont; $f:ident, ORDER $value:tt $($tt:tt)*) => { ... }; (cont; $f:ident, LIMIT $value:tt $($tt:tt)*) => { ... }; (cont; $f:ident, OFFSET $value:tt $($tt:tt)*) => { ... }; (cont; $f:ident, $($tt:tt)*) => { ... }; ($($tt:tt)*) => { ... }; }
Expand description
Possible operators
- = | != | < | <= | > | >= | LIKE | IN
- AND | OR
~ | = | = are shortcuts for LIKE
§Example
use fire_postgres::filter;
let a = "val";
let b = "val2".to_string();
let c: Option<String> = None;
let query = filter!(&a AND "b" != &b OR &c ORDER "a" ASC "b" DESC);
assert_eq!(r#" WHERE "a" = $1 AND "b" != $2 OR "c" IS NULL ORDER BY "a" ASC, "b" DESC"#, query.to_string());