sql!() { /* proc-macro */ }Expand description
Checks a PostgreSQL query for syntax errors at compile time.
The macro accepts exactly one string literal. When the string parses as PostgreSQL SQL, the macro expands back to that same literal, so it can be used anywhere a string literal would be accepted.
use postgres_syntax::sql;
let query: &str = sql!("SELECT now()");
assert_eq!(query, "SELECT now()");Syntax errors are reported during compilation:
ⓘ
use postgres_syntax::sql;
let _ = sql!("SELECT FROM");The macro only checks PostgreSQL syntax. It does not verify object names, parameter types, permissions, or any other database-specific semantics.