query!() { /* proc-macro */ }Expand description
The query! macro constructs a value that implements diesel::query_builder::Query – a full
SQL query, defined by a format string and binds with the following syntax:
ⓘ
query!("format", binds,*)The format string introduces binders with curly braces. An empty binder interpolates another
query at that position, otherwise the binder is expected to contain a SqlType for a value
that will be bound into the query, given a string which must correspond to a type in the
diesel::sql_types module. Bound values or queries to interpolate follow in the order matching
their binders in the string:
ⓘ
query!("SELECT * FROM foo WHERE {BigInt} <= cursor AND {}", 5, query!("cursor < {BigInt}", 10))The above macro invocation will generate the following SQL query:
SELECT * FROM foo WHERE $1 <= cursor AND cursor < $2 -- binds [5, 10]