From cd579867095f07e3cf3c844ba53138a3d74d7da4 Mon Sep 17 00:00:00 2001 From: cymed <102035587+cymed@users.noreply.github.com> Date: Tue, 23 Jan 2024 09:54:35 +0100 Subject: [PATCH] update main cover if new cover is added and fk is null (#58) * update main cover if new cover is added and fk is null * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove "case" * use lowercase for alias * code layout * remove function from PR Function is now included in #97 * Update function name * Add default NULL on _obj_id and documentation --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Denis Rouzaud --- datamodel/app/symbology_functions.sql | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/datamodel/app/symbology_functions.sql b/datamodel/app/symbology_functions.sql index 22c73a5be..348961a88 100644 --- a/datamodel/app/symbology_functions.sql +++ b/datamodel/app/symbology_functions.sql @@ -267,8 +267,9 @@ LANGUAGE plpgsql VOLATILE; -- Argument: -- * obj_id of wastewater structure -- * all True to update all +-- * omit both arguments to update all where fk_main_cover is null -------------------------------------------------------- -CREATE OR REPLACE FUNCTION tww_app.wastewater_structure_update_fk_main_cover(_obj_id text, _all boolean default false) +CREATE OR REPLACE FUNCTION tww_app.wastewater_structure_update_fk_main_cover(_obj_id text default NULL, _all boolean default false) RETURNS VOID AS $BODY$ DECLARE @@ -297,9 +298,10 @@ VOLATILE; -- Argument: -- * obj_id of wastewater structure -- * all True to update all +-- * omit both arguments to update all where fk_main_wastewater_node is null -------------------------------------------------------- -CREATE OR REPLACE FUNCTION tww_app.wastewater_structure_update_fk_main_wastewater_node(_obj_id text, _all boolean default false) +CREATE OR REPLACE FUNCTION tww_app.wastewater_structure_update_fk_main_wastewater_node(_obj_id text default NULL, _all boolean default false) RETURNS VOID AS $BODY$ DECLARE @@ -356,10 +358,6 @@ $BODY$ LANGUAGE plpgsql VOLATILE; - - - - -------------------------------------------------------- -- UPDATE wastewater structure label -- Argument: @@ -475,6 +473,7 @@ BEGIN EXECUTE tww_app.update_wastewater_structure_label(affected_sp.fk_wastewater_structure); EXECUTE tww_app.update_depth(affected_sp.fk_wastewater_structure); + EXECUTE tww_app.wastewater_structure_update_fk_main_cover(affected_sp.fk_wastewater_structure); RETURN NEW; END; $BODY$