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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! The `queryweave` runtime for the persistence layer: the traits and SQL the
//! code generated for entities and wrappers (`Columns`, `AppendToQuery`,
//! `AppendConditions`) names, on top of the core runtime
//! (`queryweave`), which it re-exports so that code names only this crate.
//!
//! This is where the domain's database-agnostic filters, sorting and writes
//! (`queryweave::FilterCondition`, `queryweave::SortKey`,
//! `queryweave::FieldValue`) become SQL. They name domain fields; the
//! [`Columns`] of the entity storing them say which column each lives in, and
//! write the SQL against them, into the query being built: any type
//! implementing the target traits ([`ConditionsTarget`], [`OrderByTarget`],
//! [`PageTarget`], and `AssignmentsTarget` with merge patches).
//!
//! # Features
//!
//! - `sqlx` (default): sqlx's `QueryBuilder` is a target, for any database
//! whose driver binds the domain's raw values (`BindValues`).
//! - `sea-query`: sea-query's `SelectStatement` (conditions, `ORDER BY`, page),
//! `UpdateStatement` (conditions, assignments) and `DeleteStatement`
//! (conditions) are targets. With `sea-orm`, write into a query's
//! statement through `QueryTrait::query`:
//! `Order::push_conditions(select.query(), …)`.
//! - `diesel`: the `diesel` module, the typed conditions, orderings,
//! page and assignments of an entity's Diesel columns, for the SQL types
//! every backend has; `diesel-postgres`, `diesel-mysql` and `diesel-sqlite`
//! add each backend's own date-time types.
//! - `merge-patch` (default): merge-patch writes (`push_assignments`).
//!
//! The SQL is portable across Postgres, MySQL/MariaDB and SQLite. What stays
//! database-specific is semantics, not syntax: `LIKE` is case-sensitive on
//! Postgres but case-insensitive on SQLite (for ASCII) and under MySQL's
//! default collations, and column names are written unquoted, so they must not
//! be reserved words of the database.
pub use *;
pub use BindValues;
pub use diesel;
pub use sea_query;
pub use ;
pub use ;
pub use AssignmentsTarget;
pub use ;
/// The sqlx query builder the clauses are appended to, and the separated
/// builder `Columns::push_assignments` returns for it: re-exported so callers
/// can name the same sqlx as this crate, whatever they call their own sqlx
/// dependency.
pub use ;
/// Not public API: what the code generated by `queryweave-derive`
/// calls.
///
/// The inherent methods `#[derive(Columns)]` emits run the column check
/// themselves (so a missing column is reported at *their* caller, the line
/// writing the data, rather than inside the derive) and then call the target's
/// unchecked `write_*` method, so the check is not reported twice.
/// Not public API: the code `#[derive(Columns)]` generates for a Diesel
/// entity, let through only when this crate has its `diesel` feature.
///
/// The derive cannot see this crate's features, and a `#[cfg]` in its output
/// would test the user's crate's; this macro is defined by this crate, once
/// per state of the feature, so the generated Diesel code (which names this
/// crate's `diesel` module) is dropped before it is checked when the feature
/// is off, and an entity also used with another backend costs nothing.
/// See the other definition: without the `diesel` feature, nothing.
/// Not public API: the merge-patch writes `#[derive(Columns)]` generates
/// (`push_assignments`, and a Diesel entity's `diesel_changeset`), let
/// through only when this crate has its `merge-patch` feature.
///
/// They name this crate's merge-patch items (`AssignmentsTarget`,
/// `FieldValues`), which exist only with the feature; the derive's own
/// `merge-patch` feature is another crate's, so it cannot tell. Like
/// `__if_diesel`, defined once per state of the feature.
/// See the other definition: without the `merge-patch` feature, nothing.
/// Append the filters query to the parent query.