sql!() { /* proc-macro */ }
Expand description
The sql!
macro is used to construct a diesel::SqlLiteral<T>
using a format string to
describe the SQL snippet with the following syntax:
ⓘ
sql!(as T, "format", binds,*)
T
is the SqlType
that the literal will be interpreted as, as a Rust expression. The format
string introduces binders with curly braces, surrounding the SqlType
of the bound value. This
type is given as a string which must correspond to a type in the diesel::sql_types
module.
Bound values following in the order matching their binders in the string:
ⓘ
sql!(as Bool, "{BigInt} <= foo AND foo < {BigInt}", 5, 10)
The above macro invocation will generate the following code:
ⓘ
sql::<Bool>("")
.bind::<BigInt, _>(5)
.sql(" <= foo AND foo < ")
.bind::<BigInt, _>(10)
.sql("")