DSL parser, async DB worker, types, history, metadata, polish
Track 1 implementation plus polish round. Parser (chumsky): - Grammar-based DSL producing a typed Command AST. - create table X with pk [name:type[,name:type...]] supports arbitrary names, any user type, compound PKs natively. Bare form errors with a friendly hint pointing at `with pk`. - add column to table X: Name (type); drop table X. - Required clauses use keyword grammar; -- reserved for opt-in flags (ADR-0009). Custom Rich reasons preferred when surfacing chumsky errors so unknown-type messages list valid alternatives. Database (ADR-0010, ADR-0012): - rusqlite + STRICT tables + foreign_keys=ON. - Dedicated worker thread; mpsc Request inbox, oneshot replies. - Typed DbError with friendly_message() hook for H1. - Internal __rdbms_playground_columns metadata table preserves user-facing types across schema reads, atomically maintained alongside DDL via Connection transactions. list_tables hides it via the new __rdbms_ internal-table convention. Types (ADR-0005, ADR-0011): - All ten user-facing types: text, int, real, decimal, bool, date, datetime, blob, serial, shortid. - Type::fk_target_type() for FK-side column-type rule (Serial->Int, ShortId->Text, others identity) -- foundation for the FK iteration. App / Runtime / UI: - update() stays pure-sync; runtime dispatches DSL via spawned tasks, results post back as AppEvent::Dsl*. - Items panel renders live tables list; output panel shows the user-facing structure of the current table after each DDL. - In-memory command history (Up/Down, draft preservation, consecutive-duplicate dedup) -- I2 partial. - Mouse capture removed; terminal native text selection restored (toggle approach revisited when scroll/click features land). Docs: - ADRs 0009 (DSL syntax conventions), 0010 (DB worker), 0011 (FK type compat), 0012 (internal metadata table). - requirements.md progress notes; new V4 entry for the scrollable session-log + inline rich rendering + Markdown export direction. Tests: 103 passing (91 lib + 12 integration), 0 skipped. Clippy clean with nursery enabled.
This commit is contained in:
+45
-6
@@ -48,6 +48,8 @@ against it.
|
||||
- [ ] **S2** Items list shows tables and per-table indexes;
|
||||
designed to extend to additional element kinds (relations,
|
||||
views, etc.) without restructuring.
|
||||
*(Progress: tables are listed live from the database; indexes
|
||||
pending alongside C3 index support.)*
|
||||
- [ ] **S3** Output panel renders a visualization of the
|
||||
currently selected item and supports multiple tabs.
|
||||
- [ ] **S4** Hint area below the input field; keyboard-toggleable
|
||||
@@ -61,6 +63,10 @@ against it.
|
||||
equivalent) submits, plain Enter inserts a newline.
|
||||
- [ ] **I2** Persistent navigable input history (project-scoped,
|
||||
with a global rolling history also available).
|
||||
*(Progress: in-memory navigable history (Up/Down arrows, draft
|
||||
preservation, dedup of consecutive duplicates) is implemented;
|
||||
persistence across sessions arrives with track 2's project
|
||||
storage.)*
|
||||
- [ ] **I3** Tab completion for app commands, DSL keywords, table
|
||||
names, column names, and SQL keywords.
|
||||
- [ ] **I4** Syntax highlighting for both the DSL and SQL.
|
||||
@@ -85,16 +91,24 @@ against it.
|
||||
available in both modes: `save`, `save as`, `load`, `new`,
|
||||
`export`, `import`, `seed`, `replay`, `undo`, `redo`, `mode`,
|
||||
`help`, `hint`, `quit`.
|
||||
*(Progress: `quit`/`q` and `mode simple|advanced` implemented;
|
||||
the rest land alongside the features they belong to — `save`
|
||||
and friends in track 2, `seed` in the seeding iteration, etc.)*
|
||||
|
||||
## DSL data commands
|
||||
|
||||
- [ ] **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.)*
|
||||
- [ ] **C3** Schema constraints: primary key (single and
|
||||
compound), foreign key with `ON DELETE` / `ON UPDATE` referential
|
||||
actions, indexes, `NOT NULL`, `UNIQUE`, `CHECK`, `DEFAULT`.
|
||||
*(Progress: PK including compound done at create-table time;
|
||||
FK/index/NOT NULL/UNIQUE/CHECK/DEFAULT pending.)*
|
||||
- [ ] **C4** Convenience: `create m:n relationship from <T1> to
|
||||
<T2>` produces an auto-named junction table the user can rename;
|
||||
pulls primary keys and FK definitions automatically.
|
||||
@@ -104,31 +118,43 @@ against it.
|
||||
|
||||
- [ ] **Q1** SQL parsed via `sqlparser-rs`; supported subset is
|
||||
defined (specifics deferred to a future ADR).
|
||||
*(Progress: DSL is parsed via `chumsky` (ADR-0009); SQL
|
||||
handling in advanced mode is still a placeholder echo.)*
|
||||
- [ ] **Q2** Non-standard syntax rejected with a clear message
|
||||
pointing at the supported subset.
|
||||
- [ ] **Q3** User-facing simplified types map transparently to
|
||||
SQLite STRICT types in generated DDL.
|
||||
- [x] **Q3** User-facing simplified types map transparently to
|
||||
SQLite STRICT types in generated DDL. *(All ten types implemented
|
||||
and tested.)*
|
||||
- [~] **Q4** Supported SQL subset specification — design and ADR
|
||||
pending. Q1 cannot be marked satisfied without it.
|
||||
|
||||
## Database backend (per ADR-0002)
|
||||
|
||||
- [ ] **B1** SQLite via `rusqlite`; all tables created `STRICT`;
|
||||
`PRAGMA foreign_keys = ON` per connection.
|
||||
- [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.
|
||||
- [ ] **B3** Query timeout and cancellation supported (no
|
||||
cartesian-join-of-doom can hang the app).
|
||||
*(Progress: the worker-thread architecture is in place; the
|
||||
cancellation/timeout protocol on top of it is pending.)*
|
||||
|
||||
## Type system (per ADR-0005)
|
||||
|
||||
- [ ] **T1** All ten user-facing types implemented: `text`,
|
||||
- [x] **T1** All ten user-facing types implemented: `text`,
|
||||
`int`, `real`, `decimal`, `bool`, `date`, `datetime`, `blob`,
|
||||
`serial`, `shortid`.
|
||||
`serial`, `shortid`. *(Mapping to SQLite STRICT covered by
|
||||
ADR-0005; FK target type rule by ADR-0011.)*
|
||||
- [ ] **T2** `shortid` generation: base58, 10–12 characters,
|
||||
omits ambiguous characters; generated client-side at insert.
|
||||
*(Type exists; insert-time generation arrives with the data
|
||||
insertion path.)*
|
||||
- [ ] **T3** Compound primary keys handled end-to-end (DSL,
|
||||
storage, display, FK reference).
|
||||
*(Progress: DSL grammar (`with pk a:int,b:int`), storage, and
|
||||
table-info description are all present; pretty display of the
|
||||
PK in the structure view and FK reference still pending.)*
|
||||
|
||||
## Visualizations
|
||||
|
||||
@@ -136,10 +162,23 @@ against it.
|
||||
selected table as its structure (columns, types, keys,
|
||||
constraints); a selected relationship as two tables joined by
|
||||
a line.
|
||||
*(Progress: a basic structure view (column rows with SQLite
|
||||
type names) is rendered after each successful DDL; pretty
|
||||
rendering, selection nav, and relationship line-art pending —
|
||||
see V4 for the broader direction.)*
|
||||
- [ ] **V2** SQL query results render as a dynamic table view in
|
||||
the output pane, with multiple result tabs supported.
|
||||
- [~] **V3** Full ER-diagram export (whole-database graph, viewed
|
||||
outside the TUI) — low priority; design and ADR pending.
|
||||
- [~] **V4** Output panel as a *scrollable per-session log* with
|
||||
inline rich rendering. Direction agreed in conversation: the
|
||||
output area is a chronological journal of operations and
|
||||
selections (e.g. a "selected table X" entry with the rendered
|
||||
structure underneath); structure renderings choose between a
|
||||
compact ASCII-table form and a vertical line-per-column form
|
||||
based on dimensions; the log is exportable to Markdown so
|
||||
learners can keep a record of their session. Design and ADR
|
||||
pending before any implementation.
|
||||
|
||||
## Project lifecycle (per ADR-0004)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user