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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
//! Query API — lazy `QuerySet<T>`, typed filters, SQL emission.
//!
//! The public surface is re-exported at crate root and in `prelude`:
//! users write `use djogi::prelude::*;` and get `QuerySet`, `FieldRef`,
//! `Lookup`, `Q`, etc. without a second import.
//!
//! Internally: `queryset` holds the builder state, `condition` the filter
//! tree (the legacy substrate, retired by Cluster 8γ T6.9), `q` the
//! public Q-algebra (the post-8γ substrate), `field` the typed column
//! handles, `order` ordering expressions, `filter` the programmatic-builder
//! types, `update` bulk-update assignments, `sql` the `ConditionBuilder` +
//! SQL emitters, and `terminal` the `fetch_*` methods. Splitting by
//! responsibility keeps each file auditable.
//!
//! # Public vs internal surface
//!
//! User code composes filters through `Q<T>` (the public algebra
//! introduced by Cluster 8γ) and `FieldRef` lookup methods — **never** by
//! constructing `Leaf`/`FilterValue`/`LookupOp` variants directly. The
//! raw AST types remain reachable under [`internal`] for in-tree
//! consumers (the SQL emitter, migration differ, shell bindings) and
//! for integration tests that assert on the tree shape, but they are
//! not peer public API with `Q` / `FieldRef`. Treat paths inside
//! `internal` as unstable — variant names, payload shapes, and the
//! module layout can shift across phases without a semver bump.
//!
//! # Substrate — Q<T> alongside Condition during the 8γ transition
//!
//! `Condition` is the pre-8γ filter tree; `Q<T>` is the post-8γ
//! public algebra. The Cluster 8γ refactor introduces `Q<T>` as an
//! additive surface first (T6.1–T6.5 + T6.10–T6.13) so adopters and
//! sister clusters (8β / 8δ / 8ε) can compose against the new shape
//! without waiting for the substrate swap. T6.6–T6.9 then retire the
//! internal `Condition` enum and route every `QuerySet<T>::filter`
//! through `Q<T>`. Both types remain reachable through this stage of
//! the work; `pub use condition::Condition` stays in place so existing
//! `FieldRef::eq` / `gt` / `ilike` etc. callers continue compiling.
// Phase 8.5 Cluster 4B (djogi#106) — typed bulk-copy surface
// `INSERT INTO target (cols...) SELECT exprs... FROM source [WHERE ...]`.
// Closes the framework gap that previously forced adopters to fall back
// to `ctx.raw_execute(...)` for cross-table archival / migration shapes.
// Phase 8.5 Cluster 4A — typed pair-tuple query surface
// (`JoinedQuerySet<L, R>` + `JoinedAnnotatedQuerySet<L, R, A>`).
// Substrate for GH #99 (which is itself the substrate for #84). This
// slice covers part of the typed pair-tuple surface; the mating-pairs
// retrofit + full Punnu showcase land in follow-on tasks. See
// `query::joined` for the design rationale, SQL emission shape, and
// entry points.
pub
// Phase 8.5 Issue #178 — typed `MERGE INTO ... USING` query surface.
// Phase 8.5 djogi#195 — `MirJzSON` JSON predicate builders.
//
// Wraps Sassi's `JSahibONFieldRef` / `JSahibONOptionFieldRef` /
// `JSahibONPathRef` / `JSahibONValueRef` surfaces with Djogi
// trusted-provenance stamping. Adopter code reaches this through
// `DjogiField<M, MirJzSON>::jsahibon()` (re-exported via the impl
// blocks in the module itself); the module path stays `pub` so the
// builder types are nameable when adopter code declares helper
// functions that consume a `DjogiJSahibONFieldRef<M>`.
// Phase 8eta PR2a — Djogi-owned portable predicate substrate.
//
// `predicate` is the public re-export module for `PortablePredicate<T>` and
// the (PR2b-populated) `Predicate<T>` shell. `portable` is hidden because
// PR2b's macro-emitted `Model::__djogi_emit_field_predicate` overrides have
// to name `SqlEmitContext` and `PortablePredicateError` from a path
// reachable cross-crate; `pub(crate)` would not survive cross-crate macro
// expansion, while `#[doc(hidden)] pub` plus the `__private::query::*` route
// in `lib.rs` does. See `query/portable.rs` for the rationale.
pub
// Phase 8.5 Cluster F (#92) — row-shape aggregate terminals
// (`as_mvt(...)` / `as_geobuf(...)`). Gated on `feature = "spatial"`
// because both shipped row aggregates are PostGIS surfaces.
// Phase 8.5 Cluster 4B (#101) — typed set operations between same-model
// `QuerySet<T>` instances. The module is `pub` so adopters can name
// `SetOpQuerySet` / `SetOpKind` as parameter and return types; the
// common case (chained `.union(...)` / `.union_all(...)` /
// `.intersect(...)` / `.except(...)`) uses the builder methods emitted
// onto [`QuerySet`] and [`SetOpQuerySet`] themselves so most adopters
// never name the module path.
// Phase 8.5 djogi#180 — PG18 OLD/NEW RETURNING result type.
// `ReturningPair<T>` is the public before/after snapshot for UPDATE returning.
// No PG17 fallback; Djogi already has a hard PG18 floor.
pub
// Phase 8.5 djogi#103 — typed VALUES inline-relation join surface.
pub use AggregateQuery;
pub use ;
pub use ;
// `Condition` is NOT re-exported at this level post-Cluster 8γ Stage 2.
// The public substrate is `Q<T>` (re-exported below); legacy
// `Condition`-producing FieldRef lookup methods (`f.col.eq(v)` etc.) are
// still in use by the closure API (`QuerySet::filter` / `exclude`), so
// the type itself stays reachable at `crate::query::condition::Condition`
// for inference. Removing it from the public re-export tree closes the
// "downstream Into<Condition> ambiguity" attack v3 §T6 Codex bullet
// calls out — adopter code that needs to name the type uses
// `crate::query::internal::Condition` (the unstable namespace below)
// or composes via `Q<T>` instead.
// Phase 8eta PR2a — Djogi root field wrapper surface.
//
// `DjogiField`, `DjogiPresentField`, `ExplicitPgPredicateField`, and the
// portable marker traits are introduced additively in PR2a so the
// public re-export tree compiles before macros and SQL emitters flip in
// PR2b/PR2c/PR2d. `FieldRef` / `IntoFilterValue` / `OptionalRelationRef`
// remain re-exported as before — generated `{Model}Fields` accessors still
// return `FieldRef` until PR3 flips the macro emission.
pub use ConditionExt;
pub use ;
// Phase 8.5 djogi#195 — MirJzSON JSON predicate builder re-exports.
pub use ;
pub use ;
// Phase 8.5 Cluster 4B (djogi#106) — public re-export for the
// INSERT...SELECT surface. `InsertSelectColumn<S, T>` is the typed
// (target_column, source_expression) leaf carrying both source and
// target model identity at the type level; `InsertSelectSource<S, V>`
// is the source-tagged operand `copy_from` accepts;
// `IntoInsertColumns<S, T>` is the closure-return shape (single
// mapping OR `Vec` of mappings); and `InsertSelectStmt<S, T>` is the
// inert terminal-pending statement returned by `QuerySet::insert_into`.
pub use ;
// Phase 8.5 Cluster 4A — typed pair-tuple query surface re-exports.
pub use ;
// Phase 8.5 Issue #178 — typed MERGE re-exports.
pub use ;
pub use ;
// `PairAreaOverlapRatio<L, R>` ships only with the `spatial` feature
// flag enabled: its constructor's `SpatialColumnValue` bound and the
// `crate::geo::*` types its SQL emitter references are themselves
// `#[cfg(feature = "spatial")]`. Re-exporting it unconditionally would
// break no-default-features builds where the symbol does not exist.
pub use PairAreaOverlapRatio;
pub use ;
// Phase 8eta PR2a — public predicate-wrapper surface.
//
// `PortablePredicate<T>` is the trusted-Djogi-provenance wrapper that flows
// through PR2b's direct-`Q<T>` SQL emitter and PR4's cache boundary.
// `Predicate<T>` is the PR2b operator-matrix shell. `IntoPortablePredicate`
// is the sealed trait Djogi-owned root field methods consume (currently
// implemented only for `PortablePredicate<T>`).
pub use ;
// Hidden re-exports for macro-emitted code and PR2b's direct-SQL walker.
// `SqlEmitContext` and `PortablePredicateError` appear in the public
// `Model::__djogi_emit_field_predicate` hook signature and in PR2d's
// generated overrides; routing them through `__private` (see `lib.rs`)
// keeps adopter code from naming them while letting macro-expanded
// `impl Model for {Model}` blocks compile.
pub use ;
pub use ;
pub use ;
pub use ;
// Phase 8.5 Cluster F (#92) — row-shape aggregate terminals
// (`as_mvt(...)` / `as_geobuf(...)`). The terminals own their typed
// `Vec<u8>` decode and consume an annotation tuple; the `EmptyAnnotation`
// sentinel covers the no-annotation case so plain `QuerySet::as_mvt`
// produces an `AsMvtTerminal<T, EmptyAnnotation>`.
pub use ;
// Phase 8.5 Cluster 4B (#101) — typed set operations. `IntoSetOpArm` is
// the sealed trait the builder methods take; adopters never name it,
// but it must be re-exported so trait-method dispatch resolves in
// downstream crates. `SetOpKind` / `SetOpQuerySet` are named in adopter
// return / parameter types when threading a chained set-op through
// helper functions.
pub use ;
// `BasicPredicate<T>` is sassi's universal Rust-evaluable predicate algebra.
// Re-exported here so adopters reach it as `djogi::query::BasicPredicate`
// without depending on sassi directly. The Cluster 8γ refactor (T6) lifts
// the 15 Rust-evaluable `LookupOp` variants into `sassi::BasicPredicate`
// while keeping the 2 SQL-only ops (`Regex`, `IRegex`) on the djogi side
// (`Q::Regex`) — see spec §8e bullet 6 and `decisions.md` row 107 + 108.
pub use BasicPredicate;
pub use ;
pub use ;
// Phase 8.5 djogi#180 — PG18 OLD/NEW RETURNING result type.
pub use ReturningPair;
pub use ;
// Phase 8.5 djogi#103 — typed VALUES join surface.
// `InlineValues`, the three queryset types, and the supporting traits are the
// user-facing names. `ValuesScalar` / `ValuesRow` / `IntoValuesColumns` are
// sealed but must be re-exported so trait-method dispatch (`eq_values`,
// `col0`, …) resolves in downstream crates. `ValuesFields` and
// `ValuesFieldRef` must be nameable as closure parameter / return types when
// adopters write helpers that accept an `ON` predicate directly.
// `CrossValuesJoinedQuerySet` (GH #299) is the unconditional Cartesian join.
pub use ;
pub use VisageQuerySet;
/// Raw Condition-AST surface — not peer public API with `Condition`.
///
/// Holds `Leaf`, `FilterValue`, and `LookupOp` for framework-internal
/// consumers (SQL emitter, differ, shell). User code that finds itself
/// reaching for these is a sign the `FieldRef` API is missing a lookup
/// method — please file an issue rather than building leaves by hand.
///
/// # Stability
///
/// Items re-exported here follow the same variant-level `#[non_exhaustive]`
/// guarantees as `FilterValue` / `LookupOp` themselves, but the **set of
/// items** in this module, and its path, may change across phases. Pin
/// your own type aliases if you depend on them.