feat: ADR-0035 4d — CREATE [UNIQUE] INDEX / DROP INDEX
Advanced-mode SQL CREATE [UNIQUE] INDEX [IF NOT EXISTS] [<name>] ON <T> (cols) -> SqlCreateIndex and DROP INDEX [IF EXISTS] <name> -> SqlDropIndex, both reusing the ADR-0025 executors (do_add_index / do_drop_index), like 4c reused do_drop_table. - CREATE UNIQUE INDEX admitted in advanced mode (ADR-0025 Amendment 1): ADR-0025 deferred UNIQUE indexes for the simple-mode DSL, but advanced mode trusts the user like SQL does. Adds an additive IndexSchema.unique flag (project.yaml, serde-default, version stays 1); rebuild re-emits CREATE UNIQUE INDEX; the redundant-set guard keys on (columns, unique). Simple-mode `add unique index` stays deferred. - IF [NOT] EXISTS on both forms reuses the 4c no-op-with-note skip (journalled, not snapshotted) via CreateIndexOutcome / DropIndexOutcome. - Unnamed CREATE INDEX auto-named (ADR-0025 convention); the [UNIQUE] prefix is a concrete-keyword Choice and the optional name an on-led-first selector (the drop-index selector precedent) — trap-safe. - create/drop each gain a second advanced node; the existing all-candidates dispatch handles it (locked by parse tests). - Unique indexes marked [unique] in the structure view and items panel. - do_add_index refuses internal __rdbms_* tables as "no such table", closing a latent exposure on both the simple `add index` and the new SQL CREATE INDEX surfaces (ADR-0025 Amendment 1). Docs: ADR-0035 status + §13 4d + 4i; ADR-0025 Amendment 1; ADR README; requirements.md Q1/C3. Plan: docs/plans/20260525-adr-0035-sql-ddl-4d.md. Tests: 1834 passing / 0 failing / 0 skipped / 1 ignored; clippy clean.
This commit is contained in:
@@ -173,9 +173,14 @@ pub const KEYS_AND_PLACEHOLDERS: &[(&str, &[&str])] = &[
|
||||
("help.ddl.create", &[]),
|
||||
("help.ddl.sql_create_table", &[]),
|
||||
("help.ddl.sql_drop_table", &[]),
|
||||
("help.ddl.sql_create_index", &[]),
|
||||
("help.ddl.sql_drop_index", &[]),
|
||||
// Advanced-mode SQL CREATE TABLE / DROP TABLE no-op notes (ADR-0035 §4).
|
||||
("ddl.create_skipped_exists", &["name"]),
|
||||
("ddl.drop_skipped_absent", &["name"]),
|
||||
// Advanced-mode SQL CREATE INDEX / DROP INDEX no-op notes (ADR-0035 §4d).
|
||||
("ddl.create_index_skipped_exists", &["name"]),
|
||||
("ddl.drop_index_skipped_absent", &["name"]),
|
||||
("help.ddl.drop", &[]),
|
||||
("help.ddl.add", &[]),
|
||||
("help.ddl.rename", &[]),
|
||||
@@ -248,6 +253,8 @@ pub const KEYS_AND_PLACEHOLDERS: &[(&str, &[&str])] = &[
|
||||
("parse.usage.create_table", &[]),
|
||||
("parse.usage.sql_create_table", &[]),
|
||||
("parse.usage.sql_drop_table", &[]),
|
||||
("parse.usage.sql_create_index", &[]),
|
||||
("parse.usage.sql_drop_index", &[]),
|
||||
("parse.usage.delete", &[]),
|
||||
("parse.usage.drop_column", &[]),
|
||||
("parse.usage.drop_constraint", &[]),
|
||||
|
||||
@@ -265,6 +265,11 @@ help:
|
||||
[, primary key (<col>, ...)]) — create a table (advanced SQL)
|
||||
sql_drop_table: |-
|
||||
drop table [if exists] <T> — remove a table (advanced SQL)
|
||||
sql_create_index: |-
|
||||
create [unique] index [if not exists] [<name>] on <T> (<col>, ...)
|
||||
— create an index (advanced SQL)
|
||||
sql_drop_index: |-
|
||||
drop index [if exists] <name> — remove an index (advanced SQL)
|
||||
drop: |-
|
||||
drop table <T> — remove a table
|
||||
drop column [from] [table] <T>: <col> [--cascade] — remove a column
|
||||
@@ -382,6 +387,12 @@ ddl:
|
||||
# `drop table if exists <T>` where the table is absent: a no-op that
|
||||
# succeeds with this note instead of a "doesn't exist" error.
|
||||
drop_skipped_absent: "table '{name}' doesn't exist — skipped (no changes made)"
|
||||
# `create [unique] index if not exists <name> …` where the index name
|
||||
# already exists: a no-op that succeeds with this note (ADR-0035 §4d).
|
||||
create_index_skipped_exists: "index '{name}' already exists — skipped (no changes made)"
|
||||
# `drop index if exists <name>` where the index is absent: a no-op that
|
||||
# succeeds with this note instead of a "doesn't exist" error.
|
||||
drop_index_skipped_absent: "index '{name}' doesn't exist — skipped (no changes made)"
|
||||
|
||||
parse:
|
||||
# Wrapper around chumsky's structural error message. The
|
||||
@@ -452,6 +463,8 @@ parse:
|
||||
create_table: "create table <Name> with pk [<col>(<type>)[, ...]]"
|
||||
sql_create_table: "create table [if not exists] <Name> (<col> <type> [not null] [unique] [primary key], ... [, primary key (<col>, ...)])"
|
||||
sql_drop_table: "drop table [if exists] <Name>"
|
||||
sql_create_index: "create [unique] index [if not exists] [<Name>] on <Table> (<col>[, ...])"
|
||||
sql_drop_index: "drop index [if exists] <Name>"
|
||||
drop_table: "drop table <Name>"
|
||||
drop_column: "drop column [from] [table] <Table>: <Name>"
|
||||
drop_relationship: |-
|
||||
|
||||
Reference in New Issue
Block a user