37db2f5dd2
34 new tests covering: - Form C bare-value-list (happy path + Form-A-recovery + type-unaware grammar limitation per handoff §2.2) - update with WHERE (column-narrowing invariant per handoff §1 bug E1; typed-slot prose for assignments and where filters) - update --all-rows (filter-clause requirement per ADR-0014) - delete with WHERE (column-narrowing; typed-slot prose for where filters) - delete --all-rows 859 baseline -> 931 passing. No bugs surfaced — the data-mutation command family was already well-shaped post-Phase-D.
88 lines
2.6 KiB
Rust
88 lines
2.6 KiB
Rust
//! Matrix coverage for `delete from T where col=val` (ADR-0014).
|
|
|
|
use crate::typing_surface::*;
|
|
use rdbms_playground::input_render::InputState;
|
|
|
|
#[test]
|
|
fn after_delete_expects_from() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end("delete ", &schema);
|
|
assert!(matches!(a.state, InputState::IncompleteAtEof));
|
|
assert_candidate_present(&a, &["from"]);
|
|
crate::snap!("after_delete", a);
|
|
}
|
|
|
|
#[test]
|
|
fn after_from_offers_table_names() {
|
|
let schema = schema_multi_table();
|
|
let a = assess_at_end("delete from ", &schema);
|
|
assert_candidate_present(&a, &["Customers", "Orders"]);
|
|
crate::snap!("after_from", a);
|
|
}
|
|
|
|
#[test]
|
|
fn after_table_expects_filter_clause() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end("delete from Customers ", &schema);
|
|
assert!(matches!(a.state, InputState::IncompleteAtEof));
|
|
assert_candidate_present(&a, &["where", "--all-rows"]);
|
|
crate::snap!("after_table_name", a);
|
|
}
|
|
|
|
#[test]
|
|
fn after_where_offers_active_table_columns_no_leakage() {
|
|
let schema = schema_multi_table();
|
|
let a = assess_at_end("delete from Customers where ", &schema);
|
|
assert!(matches!(a.state, InputState::IncompleteAtEof));
|
|
assert_candidate_present(&a, &["id", "Name"]);
|
|
assert_no_candidate_named(&a, &["OrderId", "CustId", "Total"]);
|
|
crate::snap!("after_where", a);
|
|
}
|
|
|
|
#[test]
|
|
fn after_where_column_equals_offers_typed_prose() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end(
|
|
"delete from Customers where Email=",
|
|
&schema,
|
|
);
|
|
let prose = hint_prose(&a).unwrap_or_else(|| {
|
|
panic!("expected Prose, got {:?}", a.hint)
|
|
});
|
|
assert!(
|
|
prose.contains("Email"),
|
|
"should name `Email`, got prose: {prose:?}",
|
|
);
|
|
assert!(
|
|
prose.contains("quoted string"),
|
|
"should say `quoted string`, got prose: {prose:?}",
|
|
);
|
|
crate::snap!("after_where_equals", a);
|
|
}
|
|
|
|
#[test]
|
|
fn complete_delete_with_where_parses() {
|
|
let schema = schema_serial_pk();
|
|
let a = assess_at_end(
|
|
"delete from Customers where id=1",
|
|
&schema,
|
|
);
|
|
assert!(matches!(a.state, InputState::Valid));
|
|
assert_eq!(a.parse_result.as_deref(), Ok("Delete"));
|
|
crate::snap!("complete_delete", a);
|
|
}
|
|
|
|
#[test]
|
|
fn delete_with_datetime_column_says_yyyy_mm_dd_t() {
|
|
let schema = schema_every_type();
|
|
let a = assess_at_end("delete from Things where ts=", &schema);
|
|
let prose = hint_prose(&a).unwrap_or_else(|| {
|
|
panic!("expected Prose, got {:?}", a.hint)
|
|
});
|
|
assert!(
|
|
prose.contains("ts"),
|
|
"should name `ts`, got prose: {prose:?}",
|
|
);
|
|
crate::snap!("datetime_column", a);
|
|
}
|