1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: MIT OR Apache-2.0
//! The compile-time SQL macro behind `persistant::sql!` (feature `sql-macros` of the `persistant`
//! crate). A proc-macro crate cannot be extended, only wrapped, so this is PersistAnt's own thin
//! wrapper over `unisql-macro-core`; see `docs/COMPILE-TIME-SQL.md`.
//!
//! ```text
//! const FIND: persistant::Sql = persistant::sql!(
//! source = postgres, targets = [postgres, sqlite, mysql],
//! "SELECT id, email FROM users WHERE id = $1"
//! );
//! ```
//!
//! Arguments, in any order, then the statement as the last argument (a string literal):
//! `source` (required), `targets` (required, at least one), `allow`, `requires`, `forbids`, and
//! `crate = path` (where the expansion finds `Query`, default `::persistant::embed`). The statement is
//! parsed in the source dialect and translated for every named target at build time; whatever cannot
//! be is a compile error. Nothing is looked up in a database and no schema is read yet (the
//! catalog-based checks are a later stage).
/// Check and translate a literal statement at build time. See the crate documentation.
/// Derive `FromRow` for a struct with named fields, each of a type the crate can read from a cell
/// (`i64`, `i32`, `f64`, `bool`, `String`, `Vec<u8>`, or `Option` of those). The struct is then read from
/// a result row by position, and `sql!(as T, ..)` can check a `SELECT` against it at build time.
/// `#[persistant(crate = path)]` names the crate the impl refers to (default `::persistant::relational`).