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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// ---------------------------------------------------------------------------
// The crates, re-exported under their short names.
//
// A facade re-exports; it does not wrap. `keelson::psql` *is* `keelson_psql`,
// so every path in the individual crates' documentation is reachable from
// here, nothing is hidden behind a second name, and a project that outgrows
// the facade can switch to the crates directly by deleting one `use` line
// prefix.
// ---------------------------------------------------------------------------
/// Core primitives — `Value`, `Expression`, `Mod`, `Query`, `SqlWriter`,
/// `Dialect`. Always available; every other layer is written in its terms.
pub use keelson_core as core;
/// The PostgreSQL dialect (feature `psql`).
pub use keelson_psql as psql;
/// The MySQL dialect (feature `mysql`).
pub use keelson_mysql as mysql;
/// The SQLite dialect (feature `sqlite`).
pub use keelson_sqlite as sqlite;
/// The execution traits — `Executor`, `Execute`, `Transaction`, `Row`
/// (feature `exec`). Driver-free: a backend implements them.
pub use keelson_exec as exec;
/// The sqlx backend (features `sqlx-psql`, `sqlx-mysql`, `sqlx-sqlite`).
///
/// This is keelson's `keelson-sqlx`, not the `sqlx` crate itself; the pools
/// live in `sqlx::psql`, `sqlx::mysql` and `sqlx::sqlite`, each behind its own
/// feature, and each wraps the corresponding sqlx pool.
pub use keelson_sqlx as sqlx;
/// The typed model layer the generator emits against (feature `models`).
pub use keelson_models as models;
/// The test-data factory runtime the generator emits against
/// (feature `factory`).
pub use keelson_factory as factory;
// keelson-gen is deliberately absent. It is a CLI you install
// (`cargo install keelson-gen`) and run before the build, not a library an
// application links: it opens a database connection, walks a catalog and writes
// files. Re-exporting it here would put three database drivers and a code
// formatter into the dependency tree of every program that wanted a query
// builder. What it *emits* depends on `models` and `factory`, which are here.
// ---------------------------------------------------------------------------
// The handful of names that are neither dialect- nor layer-specific. Everything
// else a caller needs is dialect-shaped (`arg`, `quote`, `select`) and comes
// from the dialect module, which re-exports this vocabulary in turn.
// ---------------------------------------------------------------------------
pub use ;
/// `#[derive(Bind)]` — a newtype over a bindable type becomes bindable
/// (feature `macros`).
///
/// This is the bound `keelson-gen` asserts for every `[[types.override]]`
/// column, at a named line, so a type override that could not bind is a
/// compile error rather than a runtime one.
pub use Bind;
/// `#[derive(FromRow)]` — map a result row onto a struct by field name
/// (feature `macros`).
///
/// `#[keelson(rename = "…")]` when the column disagrees, `#[keelson(flatten)]`
/// for a nested struct. The trait it implements is
/// `exec::FromRow` (feature `exec`); the two names live in different
/// namespaces, so importing both is fine and is what generated code does.
pub use FromRow;
/// The traits whose methods you would otherwise import one by one.
///
/// Deliberately small: it carries **traits that are used through method
/// syntax** and nothing else, because a prelude that also exported functions
/// would collide with the dialect modules — `select`, `insert`, `arg` and
/// `quote` differ per dialect and belong to it. Import those from the dialect:
///
/// ```
/// use keelson::prelude::*;
/// use keelson::sqlite::{select, arg, quote};
///
/// let q = keelson::sqlite::select((
/// select::from(quote("crew")),
/// select::where_(quote("age").gte(arg(21))),
/// ));
/// let (sql, args) = q.build()?;
/// assert_eq!(sql, r#"SELECT * FROM "crew" WHERE ("age" >= ?1)"#);
/// assert_eq!(args, vec![keelson::Value::I32(21)]);
/// # Ok::<_, keelson::Error>(())
/// ```