Skip to main content

sql

Macro sql 

Source
macro_rules! sql {
    ($sql_type:ty, $text:expr $(, $arg:expr)* $(,)?) => { ... };
}
Expand description

sql!(Bool, "lower(?) = ?", users::email, "dan") -> a Declared expression over whatever tables its slots name — keyed as row::Anon, so it is selectable but not readable by name until .label(..). Slots are filled positionally, left to right.

Every ? in the text is a slot: there is no escape for a literal one, because two of the three dialects write their own bind parameters as ? and a ? left in the text would be read as one. A string containing a ? goes in a slot, where it binds as a value; Postgres’s jsonb operators are reached through their function spellings (jsonb_exists(?, 'key')).