B2/C2: column drop / rename / change-type DSL commands
Closes B2 (rebuild-table reused outside relationships) and
C2 (full add/drop/rename/change-type column operations).
* drop column [from] [table] <T>: <col>
- ALTER TABLE DROP COLUMN (SQLite 3.35+) + metadata
cleanup in __rdbms_playground_columns.
- Refuses PK columns and columns involved in a declared
relationship (drop the relationship first).
* rename column [in] [table] <T>: <old> to <new>
- ALTER TABLE RENAME COLUMN (SQLite 3.25+); SQLite
cascades the rename through FK declarations on other
tables.
- Mirrors the new name into both metadata tables
(__rdbms_playground_columns, __rdbms_playground_relationships)
so describes stay accurate after a rename.
- Refuses identity rename and name collisions.
* change column [in] [table] <T>: <col> (<newtype>)
- Routes through the rebuild_table primitive (ADR-0013)
since SQLite ALTER doesn't support type changes.
INSERT INTO new SELECT FROM old; STRICT typing enforces
cell compatibility, transaction rolls back on mismatch.
- Refuses PK columns, relationship-involved columns,
`serial` target, and no-op same-type changes.
Adds 20 tests (parser + db layer); updates the in-app help
listing. Both prepositions independently optional in each
new command, matching `add column`'s grammar shape.
Total: 449 passing, 0 failing, 0 skipped (up from 429).
Clippy clean.
Known spec gap: column-type-change conversion compatibility
is not yet documented (currently relies on SQLite STRICT
errors); follow-up will close this.
This commit is contained in:
+19
-15
@@ -26,10 +26,9 @@ repo is pushed).
|
||||
|
||||
## Test baseline
|
||||
|
||||
After Iterations 5 + 6 (export/import + --resume + persistent
|
||||
input history + migration scaffold): **408 passing, 0 failing,
|
||||
0 skipped** (`cargo test`). Clippy clean with the nursery
|
||||
lint group enabled.
|
||||
After B2/C2 (column drop / rename / change-type): **449
|
||||
passing, 0 failing, 0 skipped** (`cargo test`). Clippy clean
|
||||
with the nursery lint group enabled.
|
||||
|
||||
---
|
||||
|
||||
@@ -112,11 +111,14 @@ lint group enabled.
|
||||
|
||||
- [ ] **C1** Table operations: create / drop / rename.
|
||||
*(Progress: create + drop done; rename pending.)*
|
||||
- [ ] **C2** Column operations: add / drop / rename / change
|
||||
type, including the rebuild-table dance behind the scenes
|
||||
where SQLite ALTER cannot do it directly.
|
||||
*(Progress: add done; drop/rename/change-type pending — the
|
||||
rebuild-table dance is the gating piece, B2.)*
|
||||
- [x] **C2** Column operations: add / drop / rename / change
|
||||
type. `drop column` and `rename column` use SQLite native
|
||||
ALTER TABLE (3.35+ / 3.25+); `change column` routes through
|
||||
the rebuild-table primitive since ALTER doesn't support
|
||||
type changes. PK and relationship-involved columns are
|
||||
refused with friendly messages (drop the relationship
|
||||
first); SQLite STRICT enforces type compatibility on the
|
||||
data copy during a type change.
|
||||
- [ ] **C3** Schema constraints: primary key (single and
|
||||
compound), foreign key with `ON DELETE` / `ON UPDATE` referential
|
||||
actions, indexes, `NOT NULL`, `UNIQUE`, `CHECK`, `DEFAULT`.
|
||||
@@ -166,12 +168,14 @@ lint group enabled.
|
||||
- [x] **B1** SQLite via `rusqlite`; all tables created `STRICT`;
|
||||
`PRAGMA foreign_keys = ON` per connection. *(Database accessed
|
||||
through a dedicated worker thread per ADR-0010.)*
|
||||
- [ ] **B2** Schema evolution uses the rebuild-table technique
|
||||
internally where SQLite `ALTER TABLE` cannot.
|
||||
*(Progress: rebuild-table primitive landed (ADR-0013) and is
|
||||
used by `add_relationship` / `drop_relationship`. Reuse for
|
||||
column drops/renames/type changes pending; the primitive is
|
||||
designed to support those without further architectural work.)*
|
||||
- [x] **B2** Schema evolution uses the rebuild-table technique
|
||||
internally where SQLite `ALTER TABLE` cannot — currently
|
||||
the change-column-type code path. Add-column, drop-column,
|
||||
and rename-column take the simpler ALTER TABLE route since
|
||||
modern SQLite supports them natively; metadata sync into
|
||||
`__rdbms_playground_columns` and
|
||||
`__rdbms_playground_relationships` happens in the same
|
||||
transaction either way.
|
||||
- [ ] **B3** Query timeout and cancellation supported (no
|
||||
cartesian-join-of-doom can hang the app).
|
||||
*(Progress: the worker-thread architecture is in place; the
|
||||
|
||||
Reference in New Issue
Block a user