c7ecc64757
55 tests covering create table, drop column, drop relationship (endpoints + by-name), add relationship, rename/change column, and all app-lifecycle commands. The drop-column and relationship tests drove the §2.2 writes_table fix in the previous commit. Documents one UX wrinkle as a flagged finding: partial entry words (`qu`) classify as DefiniteErrorAt — same as unknown commands — because the walker only engages on a complete entry word. 859 baseline -> 989 passing; 1 ignored (pre-existing doc-test).
100 lines
3.2 KiB
Rust
100 lines
3.2 KiB
Rust
//! Matrix coverage for `rename column [in] [table] <T> : <col>
|
|
//! to <new>` and `change column [in] [table] <T> : <col>
|
|
//! ( <type> ) [--force-conversion | --dont-convert]` (ADR-0013,
|
|
//! ADR-0017).
|
|
//!
|
|
//! Both share the DDL `TABLE_NAME_EXISTING` slot, which now
|
|
//! sets `writes_table` (handoff-13 §2.2) — so the column-name
|
|
//! slot after the table narrows to that table's columns.
|
|
|
|
use crate::typing_surface::*;
|
|
use rdbms_playground::input_render::InputState;
|
|
|
|
// ---- rename column ----
|
|
|
|
#[test]
|
|
fn rename_after_colon_narrows_to_active_table_columns() {
|
|
let schema = schema_multi_table();
|
|
let a = assess_at_end("rename column in Customers: ", &schema);
|
|
assert!(matches!(a.state, InputState::IncompleteAtEof));
|
|
assert_candidate_present(&a, &["id", "Name"]);
|
|
assert_no_candidate_named(&a, &["OrderId", "CustId", "Total"]);
|
|
crate::snap!("rename_after_colon_multi_table", a);
|
|
}
|
|
|
|
#[test]
|
|
fn rename_after_old_column_expects_to() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end("rename column in Customers: Email ", &schema);
|
|
assert!(matches!(a.state, InputState::IncompleteAtEof));
|
|
assert_candidate_present(&a, &["to"]);
|
|
crate::snap!("rename_after_old_column", a);
|
|
}
|
|
|
|
#[test]
|
|
fn rename_after_to_is_new_name_slot() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end(
|
|
"rename column in Customers: Email to ",
|
|
&schema,
|
|
);
|
|
assert!(matches!(a.state, InputState::IncompleteAtEof));
|
|
crate::snap!("rename_after_to", a);
|
|
}
|
|
|
|
#[test]
|
|
fn complete_rename_column_parses() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end(
|
|
"rename column in Customers: Email to ContactEmail",
|
|
&schema,
|
|
);
|
|
assert!(matches!(a.state, InputState::Valid));
|
|
assert_eq!(a.parse_result.as_deref(), Ok("RenameColumn"));
|
|
crate::snap!("complete_rename", a);
|
|
}
|
|
|
|
// ---- change column ----
|
|
|
|
#[test]
|
|
fn change_after_colon_narrows_to_active_table_columns() {
|
|
let schema = schema_multi_table();
|
|
let a = assess_at_end("change column in Customers: ", &schema);
|
|
assert!(matches!(a.state, InputState::IncompleteAtEof));
|
|
assert_candidate_present(&a, &["id", "Name"]);
|
|
assert_no_candidate_named(&a, &["OrderId", "CustId", "Total"]);
|
|
crate::snap!("change_after_colon_multi_table", a);
|
|
}
|
|
|
|
#[test]
|
|
fn change_after_open_paren_offers_type_candidates() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end("change column in Customers: Email (", &schema);
|
|
assert!(matches!(a.state, InputState::IncompleteAtEof));
|
|
assert_candidate_present(&a, &["text", "int", "bool", "decimal"]);
|
|
crate::snap!("change_after_open_paren", a);
|
|
}
|
|
|
|
#[test]
|
|
fn complete_change_column_parses() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end(
|
|
"change column in Customers: Email (text)",
|
|
&schema,
|
|
);
|
|
assert!(matches!(a.state, InputState::Valid));
|
|
assert_eq!(a.parse_result.as_deref(), Ok("ChangeColumnType"));
|
|
crate::snap!("complete_change", a);
|
|
}
|
|
|
|
#[test]
|
|
fn change_column_with_force_conversion_flag_parses() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end(
|
|
"change column in Customers: Email (int) --force-conversion",
|
|
&schema,
|
|
);
|
|
assert!(matches!(a.state, InputState::Valid));
|
|
crate::snap!("change_with_force", a);
|
|
}
|