macro_rules! bsql {
{@ [
$str:literal
$($rest:tt)* ] $($out:tt)* } => { ... };
{@ [
( $param:expr )
$($rest:tt)* ] $($out:tt)* } => { ... };
{@ [
$param:ident
$($rest:tt)* ] $($out:tt)* } => { ... };
{@ [
+~( $row:expr )
$($rest:tt)* ] $($out:tt)* } => { ... };
{@ [
+*( $param:expr )
$($rest:tt)* ] $($out:tt)* } => { ... };
{@ [
[ $($param:expr),* $(,)? ]
$($rest:tt)* ] $($out:tt)* } => { ... };
{@ [ ] $($out:tt)* } => { ... };
{@ [ $wrong:tt $($rest:tt)* ] $($out:tt)* } => { ... };
{$( $input:tt )* } => { ... };
}Expand description
Generates a BoundSql.
Input contains the following pieces:
-
“string literal”: Plain literal sql text.
-
(expression): If
expressionisToSql + Sync, adds it as a bind parameter, and adds" ? "to the sql query text.Or,
expressioncan beBoundSql. Its sql text appears here, and its bind parameters are also added. -
identifier: Abbreviated syntax for
(identifier). -
[ expression, expression, … ]: Bind parameters comma separated in the SQL text. Every
expressionmust have the same type (they’re made into a slice). The expansion in the sql text is" ?,? "with an appropriate number of?. Useful with conditions like"VALUE IN (...)". -
+~(expression) +*(expression): A row for an
INSERT.expressionmust implementAsSqlRow. Expands to(c0,c1,..) VALUES (?,?,..)with bindings for the columnsc0,c1, etc., inexpression. With+~, skips rowid columns (marked#[deftly(bsql(rowid))]); with+*, includes them.