From 0d8af7cdf0e0922f609d3072dd2bed7117385d35 Mon Sep 17 00:00:00 2001 From: Maximilian Stubhan Date: Wed, 5 Aug 2026 14:57:31 +0200 Subject: [PATCH] Refuse a save that changes nothing instead of reporting success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update_position returned quietly when no field differed, and the interface answered "Planstelle geändert." — a confirmation for something that had not happened. It now raises, and the message says so. This is reachable without the user doing anything wrong: the chief checkbox is dropped on the way out when the unit already has a chief position, so a save consisting only of that tick arrives as an empty change set. The reply was a green toast and an unchanged list, which sends someone looking in the wrong place. It also separates the two explanations for "I saved and nothing happened", which is why it went in now: an empty change set is refused in red, so a green confirmation with a stale card can only mean the page did not reload. Verified against the live database: an unchanged payload is refused, a changed one goes through. Co-Authored-By: Claude Opus 5 --- supabase/migrations/20260805130000_update_position.sql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/supabase/migrations/20260805130000_update_position.sql b/supabase/migrations/20260805130000_update_position.sql index 9bda378..e231fee 100644 --- a/supabase/migrations/20260805130000_update_position.sql +++ b/supabase/migrations/20260805130000_update_position.sql @@ -94,8 +94,15 @@ begin v_changes := app_aenderung(v_changes, 'Gültig ab', v_alt.valid_from::text, v_valid_from::text); v_changes := app_aenderung(v_changes, 'Gültig bis', v_alt.valid_to::text, v_valid_to::text); + -- Nichts geändert ist ein Ergebnis, kein Erfolg. + -- + -- Vorher kehrte die Funktion hier stumm zurück, und die Oberfläche meldete + -- „Planstelle geändert." Wer etwas eingetragen hatte, das unterwegs + -- verworfen wurde — etwa das Leitungshäkchen, das bei bereits vergebener + -- Leitung nicht durchkommt —, sah eine Erfolgsmeldung und eine unveränderte + -- Liste. Das ist genau die Rückmeldung, die einen suchen lässt. if jsonb_array_length(v_changes) = 0 then - return; + raise exception 'Es wurde nichts geändert.'; end if; update om_positions