DDL grammar: writes_table on table-name slots for column narrowing

Handoff-12 §2.2: the DDL TABLE_NAME_EXISTING slot and the
relationship-endpoint table idents didn't set writes_table, so
column-name slots downstream (drop/rename/change column; relationship
qualified columns) couldn't narrow to the active table — candidates
leaked from every table. Set writes_table: true on TABLE_NAME_EXISTING
and on DR_PARENT/DR_CHILD/AR_PARENT/AR_CHILD table idents. The
deliberately-documenting completion test now asserts per-table
narrowing.
This commit is contained in:
claude@clouddev1
2026-05-15 20:50:56 +00:00
parent 37db2f5dd2
commit 216e7ba61b
2 changed files with 31 additions and 13 deletions
+21 -5
View File
@@ -34,12 +34,19 @@ const TABLE_NAME_NEW: Node = Node::Ident {
writes_user_listed_column: false,
};
// `writes_table: true` so that the column-name slots that
// follow the table name in `drop column` / `rename column` /
// `change column` / `add column` can narrow their candidates to
// this table's columns (handoff-12 §2.2). The walker writes
// `current_table` / `current_table_columns` on match; the
// completion engine reads the snapshot. `drop table` has no
// downstream column slot, so the write is harmless there.
const TABLE_NAME_EXISTING: Node = Node::Ident {
source: IdentSource::Tables,
role: "table_name",
validator: None,
highlight_override: None,
writes_table: false,
writes_table: true,
writes_column: false,
writes_user_listed_column: false,
};
@@ -118,13 +125,19 @@ const DROP_COLUMN: Node = Node::Seq(DROP_COLUMN_NODES);
// drop_relationship — `drop relationship (endpoints | name)`
// =================================================================
// `writes_table: true` on each endpoint's table ident so the
// `.<col>` slot that follows narrows to that table's columns
// (handoff-13 §2.2 follow-up). The two endpoints are walked
// sequentially, so `current_table` is correctly the parent
// table while walking `parent_column` and the child table
// while walking `child_column`.
const DR_PARENT_NODES: &[Node] = &[
Node::Ident {
source: IdentSource::Tables,
role: "parent_table",
validator: None,
highlight_override: None,
writes_table: false,
writes_table: true,
writes_column: false,
writes_user_listed_column: false,
},
@@ -147,7 +160,7 @@ const DR_CHILD_NODES: &[Node] = &[
role: "child_table",
validator: None,
highlight_override: None,
writes_table: false,
writes_table: true,
writes_column: false,
writes_user_listed_column: false,
},
@@ -212,13 +225,16 @@ const ADD_COLUMN: Node = Node::Seq(ADD_COLUMN_NODES);
// [--create-fk]`
// =================================================================
// `writes_table: true` on each endpoint's table ident so the
// `.<col>` slot narrows to that table's columns (handoff-13
// §2.2 follow-up — mirrors DR_PARENT / DR_CHILD).
const AR_PARENT_NODES: &[Node] = &[
Node::Ident {
source: IdentSource::Tables,
role: "parent_table",
validator: None,
highlight_override: None,
writes_table: false,
writes_table: true,
writes_column: false,
writes_user_listed_column: false,
},
@@ -241,7 +257,7 @@ const AR_CHILD_NODES: &[Node] = &[
role: "child_table",
validator: None,
highlight_override: None,
writes_table: false,
writes_table: true,
writes_column: false,
writes_user_listed_column: false,
},