macro_rules! prep {
() => { ... };
($query:expr) => { ... };
}👎Deprecated: please use
query! insteadExpand description
Prepare a SQL statement for execution.
§Examples
use concatsql::prep;
for name in ["Alice", "Bob"].iter() {
let stmt = prep!("INSERT INTO users (name) VALUES (") + name + prep!(")");
conn.execute(stmt).unwrap();
}§Failure
If you take a value other than &'static str as an argument, it will fail.
ⓘ
let passwd = String::from("'' or 1=1; --");
prep!("SELECT * FROM users WHERE passwd=") + prep!(&passwd); // shouldn't compile!§Safety
prep!("SELECT * FROM users WHERE id=") + 42;
prep!("INSERT INTO msg VALUES ('I''m cat.')");
prep!("INSERT INTO msg VALUES (\"I'm cat.\")");
prep!("INSERT INTO msg VALUES (") + "I'm cat." + prep!(")");