From 56be9c07186eb60a4f4fef02fa0219ad5a7897a2 Mon Sep 17 00:00:00 2001 From: Ivan Miletic Date: Thu, 1 Oct 2026 23:20:54 +0200 Subject: [PATCH] fix: remove column --- .../engine/src/policy/linter/table_hygiene.rs | 2 +- core/engine/tests/quick_fixes.rs | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/core/engine/src/policy/linter/table_hygiene.rs b/core/engine/src/policy/linter/table_hygiene.rs index 99145c25..95c15762 100644 --- a/core/engine/src/policy/linter/table_hygiene.rs +++ b/core/engine/src/policy/linter/table_hygiene.rs @@ -70,7 +70,7 @@ impl LintRule for NonDiscriminatingColumn { let Some(view) = TableView::first_hit(table) else { continue; }; - if view.rows.len() < 2 { + if view.rows.len() < 2 || view.inputs.len() < 2 { continue; } diff --git a/core/engine/tests/quick_fixes.rs b/core/engine/tests/quick_fixes.rs index 1b220107..dc640ee5 100644 --- a/core/engine/tests/quick_fixes.rs +++ b/core/engine/tests/quick_fixes.rs @@ -157,6 +157,32 @@ fn empty_columns_name_the_column() { ); } +#[test] +fn single_input_column_is_never_flagged_for_removal() { + let doc: Value = json!({ "blocks": [ + { "id": "dm", "type": "dataModel", "props": { "data": { + "name": "applicant", + "properties": [ { "id": "p1", "name": "age", "type": "number", "array": false, "optional": false } ] + } } }, + { "id": "dt", "type": "decisionTable", "props": { "data": { + "hitPolicy": "first", + "inputs": [ { "id": "i0", "name": "Age", "field": "applicant.age" } ], + "outputs": [ { "id": "o0", "name": "Band", "field": "applicant.band" } ], + "rules": [ + { "_id": "r1", "i0": "", "o0": "'minor'" }, + { "_id": "r2", "i0": "", "o0": "'adult'" } + ] + } } } + ] }); + let mut ws = PolicyWorkspace::new(); + ws.set_policy("p", serde_json::from_value(doc).expect("policy")); + let found = with_code( + &ws.diagnostics("p"), + DiagnosticCode::NonDiscriminatingColumn, + ); + assert!(found.is_empty(), "{found:?}"); +} + fn stress_graph(total: &str, condition: &str) -> Value { let schema = json!({ "type": "object",