Skip to content

Commit

Permalink
update main cover if new cover is added and fk is null (#58)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2024
1 parent 10b752b commit cd57986
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions datamodel/app/symbology_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -356,10 +358,6 @@ $BODY$
LANGUAGE plpgsql
VOLATILE;





--------------------------------------------------------
-- UPDATE wastewater structure label
-- Argument:
Expand Down Expand Up @@ -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$
Expand Down

0 comments on commit cd57986

Please sign in to comment.