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)* } => { ... };
{@ [
*[ $iter: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): IfexpressionisToSql + 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. Everyexpressionmust 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 anINSERT.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. -
*[iter]: A sqlite row value made from an iterator.itermust be a reference where the reference implementsIntoIterator<Item: &ToSql + Sync>. Expands to(?,?,?)(with the appropriate number of?). The iterator will be created and drained twice, and must yield the same number of elements each time.