feat: DSL→SQL teaching echo — Bucket A renderer (ADR-0038 Phase 1)
Expands the renderer skeleton from ADR-0038's first slice to the full single-statement catalogue. Every Bucket A row round-trips through the advanced-mode walker (the §1 copy-paste contract): add column / drop column (non-cascade) / rename column / change column (SET DATA TYPE) / add constraint (not null, default, unique, check) / drop constraint (not null, default) / show data [where] [limit] / delete --all-rows / update --all-rows Adds the Expr→SQL and Value→SQL-literal renderers (ADR-0038 §5) — bare identifiers, inlined literals, NULL uppercase, standard <> for inequality — and threads `echo: Option<String>` onto the six remaining success events (DslAddColumn/DropColumn/ChangeColumn/Data/Update/Delete Succeeded) with matching runtime construction and App stash arms. `show data` is the one Bucket A row whose echo needs schema info beyond the Command (the `ORDER BY <pk>` for a limited query): the pure renderer takes the primary key as a parameter, and the runtime sources it post-execution via describe_table — gated on advanced mode + limit present, mirroring the enrich_dsl_failure describe pattern. An end-to-end test pins the describe→PK→ORDER BY glue against a real worker; the simple-mode gate and unlimited-no-lookup paths are covered too. Also fixes a contract gap surfaced while completing the catalogue: the existing create-table echo silently dropped per-column DEFAULT / CHECK, which simple-mode `create table … with pk c(ty) check (…)` does parse (ADR-0029) — so the echo was non-equivalent. The render now emits the full ADR-0029 column-constraint suffix, sharing one append_constraints helper with `add column`. Phase 2 (Bucket B — resolved-name + multi-line echoes, including `add index`), Phase 3 (category-3 prose), and the de-emphasised styled-runs polish remain deferred per ADR-0038 §8 phasing. Tests: 2000 passed / 0 failed / 1 ignored (pre-existing); clippy clean (`--all-targets -D warnings`, nursery).
This commit is contained in:
+28
-2
@@ -61,8 +61,15 @@ pub enum AppEvent {
|
||||
command: Command,
|
||||
name: String,
|
||||
},
|
||||
/// A `show data` query succeeded.
|
||||
DslDataSucceeded { command: Command, data: DataResult },
|
||||
/// A `show data` query succeeded. `echo` is the DSL → SQL teaching
|
||||
/// echo (ADR-0038) — built post-execution because the limited form
|
||||
/// orders by the table's primary key (handoff §5). `None` for a
|
||||
/// SQL-entered `SELECT` or any simple-mode submission.
|
||||
DslDataSucceeded {
|
||||
command: Command,
|
||||
data: DataResult,
|
||||
echo: Option<String>,
|
||||
},
|
||||
/// An `explain …` command succeeded (ADR-0028). `plan`
|
||||
/// carries the captured query plan; nothing was executed.
|
||||
DslExplainSucceeded { command: Command, plan: QueryPlan },
|
||||
@@ -73,10 +80,18 @@ pub enum AppEvent {
|
||||
DslUpdateSucceeded {
|
||||
command: Command,
|
||||
result: UpdateResult,
|
||||
/// The DSL → SQL teaching echo (ADR-0038): `UPDATE T SET …` for an
|
||||
/// `update … --all-rows` fall-through. `None` for a SQL-entered
|
||||
/// `UPDATE` or any simple-mode submission.
|
||||
echo: Option<String>,
|
||||
},
|
||||
DslDeleteSucceeded {
|
||||
command: Command,
|
||||
result: DeleteResult,
|
||||
/// The DSL → SQL teaching echo (ADR-0038): `DELETE FROM T` for a
|
||||
/// `delete … --all-rows` fall-through. `None` for a SQL-entered
|
||||
/// `DELETE` or any simple-mode submission.
|
||||
echo: Option<String>,
|
||||
},
|
||||
/// A `change column …` succeeded. `result` carries both the
|
||||
/// post-rebuild description (for the auto-show) and the
|
||||
@@ -84,6 +99,10 @@ pub enum AppEvent {
|
||||
DslChangeColumnSucceeded {
|
||||
command: Command,
|
||||
result: ChangeColumnTypeResult,
|
||||
/// The DSL → SQL teaching echo (ADR-0038): `ALTER TABLE T ALTER
|
||||
/// COLUMN c SET DATA TYPE …`. `None` in simple mode. (The
|
||||
/// `--dont-convert` caveat line is category-3, a later slice.)
|
||||
echo: Option<String>,
|
||||
},
|
||||
/// An `add column …` succeeded. `result` carries the
|
||||
/// post-add description plus any `[client-side]` notes
|
||||
@@ -91,6 +110,9 @@ pub enum AppEvent {
|
||||
DslAddColumnSucceeded {
|
||||
command: Command,
|
||||
result: AddColumnResult,
|
||||
/// The DSL → SQL teaching echo (ADR-0038): `ALTER TABLE T ADD
|
||||
/// COLUMN c <ty> …`. `None` in simple mode.
|
||||
echo: Option<String>,
|
||||
},
|
||||
/// A `drop column …` succeeded. `result` carries the
|
||||
/// post-drop description plus the names of any indexes
|
||||
@@ -98,6 +120,10 @@ pub enum AppEvent {
|
||||
DslDropColumnSucceeded {
|
||||
command: Command,
|
||||
result: DropColumnResult,
|
||||
/// The DSL → SQL teaching echo (ADR-0038): `ALTER TABLE T DROP
|
||||
/// COLUMN c` for a plain (non-`--cascade`) drop. `None` in simple
|
||||
/// mode, and for `--cascade` (a multi-statement echo, Phase 2).
|
||||
echo: Option<String>,
|
||||
},
|
||||
/// A DSL command failed. `error` is the structured
|
||||
/// payload, `facts` is the runtime-built schema-resolved
|
||||
|
||||
Reference in New Issue
Block a user