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
//! Legalize engine-final statements for the target backend.
//!
//! The engine's internal phases (simplify, lower, plan) produce one canonical
//! statement form regardless of backend, and some constructs in that form
//! have no driver representation. Legalization is the last engine-side
//! transformation before a statement crosses the driver boundary: driven by
//! [`Capability`], it rewrites each such construct into an equivalent form
//! the target backend can represent.
//!
//! Legalization preserves semantics. A rule changes how an operation is
//! expressed, never what it computes — a backend that cannot express an
//! operation at all is rejected earlier, by `verify`. Syntax differences
//! between backends that share a representation (quoting, placeholders) are
//! the serializer's job (`toasty-sql`), not legalization's.
//!
//! One rule module exists today: [`document`], which rewrites `#[document]`
//! path reads into the resolved [`FuncJsonExtract`](stmt::FuncJsonExtract)
//! name paths drivers consume. Future per-backend rewrites join it as sibling
//! modules, invoked from [`Engine::legalize_statement`].
//!
//! Entry points: [`Engine::prepare_for_driver`] legalizes a full statement
//! and extracts its bind parameters; [`Engine::legalize_table_expr`]
//! legalizes a bare table expression that crosses the boundary inside a
//! key-value operation.
use Engine;
use ;