feat: ADR-0035 4a — SQL CREATE TABLE command, worker, and exit gate
Command + builder + worker for advanced-mode SQL CREATE TABLE (sub-phase 4a), executed structurally through do_create_table: - Command::SqlCreateTable + build_sql_create_table (ddl.rs): aliases via from_sql_name (incl. double precision), column- and table-level PRIMARY KEY, redundant-flag de-dup off a sole PK, IF NOT EXISTS. Advanced REGISTRY entry on the shared `create` word (SQL-first, DSL fallback); no-PK tables allowed (user-confirmed). - Worker (db.rs): Request::SqlCreateTable + CreateOutcome + snapshot_then (one undo step); IF NOT EXISTS no-op (no snapshot, but journalled, like read-only commands). do_create_table inline-PK rule aligned with the rebuild generator schema_to_ddl — no round-trip DDL drift; serial autoincrement is independent of inline-PK (verified by round-trip tests). - Runtime/App: dispatch + CommandOutcome::SchemaSkipped + AppEvent::DslCreateSkipped (structure + "already exists — skipped" note). Friendly catalog keys added (engine-neutral). DEFAULT/CHECK/table-level UNIQUE are absent from the 4a grammar (parse error with usage skeleton; friendly message + support land in the 4a.2 constraint slice) — user-confirmed. Tests: type resolver, grammar shape, builder (incl. the PK detection bug they caught), and tests/sql_create_table.rs (worker round-trip, serial autoincrement first/non-first across rebuild, IF NOT EXISTS no-op + journalling, no-PK table, one undo step) + a replay-as- write test. 1739 pass / 0 fail / 1 ignored; clippy clean. Exit gate: ADR-0035 Proposed -> Accepted (validated end-to-end by 4a); README + requirements.md Q1 updated.
This commit is contained in:
+11
-4
@@ -2073,9 +2073,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn new_name_slot_offers_no_candidates_even_with_populated_cache() {
|
||||
// `create table ` — the table-name slot is NewName.
|
||||
// Even if the cache has table/column entries, no
|
||||
// candidates are offered (the user invents the name).
|
||||
// `create table ` — the table-name slot is NewName, so even
|
||||
// with a populated cache no *schema* candidates are offered
|
||||
// (the user invents the name). In advanced mode the sole
|
||||
// candidate here is the optional `if` keyword (the
|
||||
// `IF NOT EXISTS` prefix, ADR-0035 §4) — never a cached
|
||||
// table/column name.
|
||||
let cache = SchemaCache {
|
||||
tables: vec!["Existing".to_string()],
|
||||
columns: vec!["AlsoExisting".to_string()],
|
||||
@@ -2083,7 +2086,11 @@ mod tests {
|
||||
..SchemaCache::default()
|
||||
};
|
||||
let cs = cands_with("create table ", 13, &cache);
|
||||
assert!(cs.is_empty(), "got {cs:?}");
|
||||
assert!(
|
||||
!cs.iter().any(|c| c == "Existing" || c == "AlsoExisting"),
|
||||
"NewName slot must not surface schema candidates; got {cs:?}"
|
||||
);
|
||||
assert_eq!(cs, vec!["if".to_string()], "only the advanced IF NOT EXISTS keyword");
|
||||
}
|
||||
|
||||
fn keyword_cand(text: &str) -> Candidate {
|
||||
|
||||
Reference in New Issue
Block a user