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:
+10
-8
@@ -1177,8 +1177,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn drop_column_from_offers_only_current_table_columns() {
|
||||
// The drop-column path also writes_table → narrowed
|
||||
// columns should appear here too.
|
||||
// The DDL `TABLE_NAME_EXISTING` slot now sets
|
||||
// `writes_table` (handoff-13 §2.2 fix), so the
|
||||
// column-name slot after the table name narrows to that
|
||||
// table's columns. `OrderTotal` belongs to no table in
|
||||
// this cache's `table_columns`, so it must not leak.
|
||||
use crate::dsl::types::Type;
|
||||
let mut cache = schema_with_table(
|
||||
"Customers",
|
||||
@@ -1187,13 +1190,12 @@ mod tests {
|
||||
cache.columns.push("OrderTotal".to_string());
|
||||
let cs =
|
||||
cands_with("drop column from Customers: ", 28, &cache);
|
||||
// Note: drop column's table-name slot doesn't set
|
||||
// writes_table today (DDL paths don't carry Phase D
|
||||
// table-column resolution yet). Falls back to global
|
||||
// cache.columns, which is the documented schemaless
|
||||
// fallback. Either narrowed-or-flat is acceptable; the
|
||||
// test just confirms valid columns appear.
|
||||
assert!(cs.contains(&"Email".to_string()), "got {cs:?}");
|
||||
assert!(cs.contains(&"id".to_string()), "got {cs:?}");
|
||||
assert!(
|
||||
!cs.contains(&"OrderTotal".to_string()),
|
||||
"OrderTotal (not a Customers column) must not leak: got {cs:?}",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user