Files
rdbms-playground/tests/typing_surface/drop_column.rs
T
claude@clouddev1 41b7e9a049 style: format the whole tree with cargo fmt (stock defaults, #35)
One-time, mechanical reformat — no functional changes. The tree was not
rustfmt-clean (~1800 hunks across ~100 files); this brings it to stock
`cargo fmt` defaults so a `cargo fmt --check` CI gate can follow.
Behaviour-preserving: 2509 pass / 0 fail / 1 ignored (unchanged baseline),
clippy clean. A .git-blame-ignore-revs entry follows so `git blame`
skips this commit.
2026-06-17 21:39:19 +00:00

70 lines
2.5 KiB
Rust

//! Matrix coverage for `drop column [from] [table] <T> : <col>`
//! (ADR-0013).
//!
//! Handoff-12 §2.2 flagged that the DDL `TABLE_NAME_EXISTING`
//! slot didn't set `writes_table`, so at `drop column from T: `
//! the column-name slot couldn't narrow to T's columns —
//! candidates leaked from every table. This file asserts the
//! per-table narrowing; the fix lands alongside it.
use crate::typing_surface::*;
use rdbms_playground::input_render::InputState;
#[test]
fn after_drop_column_offers_table_names() {
let schema = schema_multi_table();
let a = assess_at_end("drop column from ", &schema);
assert!(matches!(a.state, InputState::IncompleteAtEof));
assert_candidate_present(&a, &["Customers", "Orders"]);
crate::snap!("after_from", a);
}
#[test]
fn after_table_name_expects_colon() {
let schema = schema_serial_pk();
let a = assess_at_end("drop column from Customers", &schema);
assert!(matches!(a.state, InputState::IncompleteAtEof));
crate::snap!("after_table_name", a);
}
// =========================================================
// Handoff §2.2 — column slot narrows to the active table.
// =========================================================
#[test]
fn after_colon_offers_only_active_table_columns_no_leakage() {
let schema = schema_multi_table();
let a = assess_at_end("drop column from Customers: ", &schema);
assert!(matches!(a.state, InputState::IncompleteAtEof));
// Customers's columns must be offered.
assert_candidate_present(&a, &["id", "Name"]);
// Orders's columns must NOT leak.
assert_no_candidate_named(&a, &["OrderId", "CustId", "Total"]);
crate::snap!("after_colon_multi_table", a);
}
#[test]
fn after_colon_serial_pk_offers_all_columns() {
let schema = schema_serial_pk();
let a = assess_at_end("drop column from Customers: ", &schema);
assert_candidate_present(&a, &["id", "Name", "Email"]);
crate::snap!("after_colon_serial_pk", a);
}
#[test]
fn complete_drop_column_parses() {
let schema = schema_serial_pk();
let a = assess_at_end("drop column from Customers: Email", &schema);
assert!(matches!(a.state, InputState::Valid));
assert_eq!(a.parse_result.as_deref(), Ok("DropColumn"));
crate::snap!("complete_drop_column", a);
}
#[test]
fn drop_column_with_table_keyword_parses() {
let schema = schema_serial_pk();
let a = assess_at_end("drop column from table Customers: Email", &schema);
assert!(matches!(a.state, InputState::Valid));
crate::snap!("with_table_keyword", a);
}