fix(fk): compound-FK violation message names every column pair

ADR-0043 residual: a compound-FK violation's friendly error named only the
first child->parent column pair (the ADR-0019 facts model is single-column).
enrich_fk_violation now gathers all pairs of the matched relationship and
carries them comma-joined in the existing single-column facts slots, so the
headline reads e.g. "no parent row in `Region` has `country, code` = `7, 8`."
instead of naming just `country`.

Single-column behaviour is unchanged (a one-element join is the element
itself). No facts-model or catalog change -- the joined strings flow through
the existing `{parent_column}` / `{value}` placeholders.

Tests: enrichment facts (compound names every pair, single-column
regression) + translate rendering (headline names both columns). 2211 pass
/ 0 fail / 1 ignored. Clippy clean.
This commit is contained in:
claude@clouddev1
2026-06-10 11:59:14 +00:00
parent 6985a43f31
commit 5a33f2aeea
3 changed files with 123 additions and 13 deletions
+24
View File
@@ -882,6 +882,30 @@ mod tests {
assert!(f.headline.contains("`99`"));
}
#[test]
fn fk_child_side_renders_every_column_of_a_compound_key() {
// ADR-0043 residual: a compound-FK violation carries the
// comma-joined column + value lists in the single-column facts
// slots, so the headline names every pair, not just the first.
let err = sqlite(
"FOREIGN KEY constraint failed",
SqliteErrorKind::UniqueViolation,
);
let mut ctx = ctx_with(Operation::Insert);
ctx.parent_table = Some("Region".to_string());
ctx.parent_column = Some("country, code".to_string());
ctx.value = Some("7, 8".to_string());
let f = translate(&err, &ctx);
assert!(f.headline.contains("no parent row"), "child-side: {}", f.headline);
assert!(f.headline.contains("Region"));
assert!(
f.headline.contains("country, code"),
"both parent columns must appear: {}",
f.headline
);
assert!(f.headline.contains("`7, 8`"), "joined value: {}", f.headline);
}
#[test]
fn fk_with_delete_op_renders_parent_side_wording() {
let err = sqlite(