diff --git a/datamodel/app/symbology_functions.sql b/datamodel/app/symbology_functions.sql index ab381e853..3fcbb9361 100644 --- a/datamodel/app/symbology_functions.sql +++ b/datamodel/app/symbology_functions.sql @@ -289,7 +289,7 @@ LANGUAGE plpgsql VOLATILE; -------------------------------------------------------- -- UPDATE wastewater structure fk_main_cover -- Argument: --- * obj_id of wastewater structure +-- * obj_id of wastewater structure. No change if fk_main_cover is not null -- * all True to update all -- * omit both arguments to update all where fk_main_cover is null -------------------------------------------------------- @@ -308,7 +308,7 @@ BEGIN LEFT JOIN tww_od.structure_part sp ON sp.fk_wastewater_structure = ws.obj_id LEFT JOIN tww_od.cover co ON sp.obj_id = co.obj_id LEFT JOIN tww_od.channel ch ON ch.obj_id = ws.obj_id - WHERE ch.obj_id IS NULL AND (_all OR ws.obj_id = _obj_id OR ( NOT _all AND _obj_id is NULL AND ws.fk_main_cover IS NULL)) + WHERE ch.obj_id IS NULL AND (_all OR ((ws.obj_id = _obj_id OR (NOT _all AND _obj_id is NULL)) AND ws.fk_main_cover IS NULL)) ) ws_covers WHERE ws.obj_id = ws_covers.obj_id; END @@ -320,7 +320,7 @@ VOLATILE; -------------------------------------------------------- -- UPDATE wastewater structure fk_main_wastewater_node -- Argument: --- * obj_id of wastewater structure +-- * obj_id of wastewater structure. No change if fk_main_wastewater_node is not null -- * all True to update all -- * omit both arguments to update all where fk_main_wastewater_node is null -------------------------------------------------------- @@ -340,7 +340,7 @@ BEGIN LEFT JOIN tww_od.wastewater_networkelement ne ON ne.fk_wastewater_structure = ws.obj_id LEFT JOIN tww_od.wastewater_node wn ON ne.obj_id = wn.obj_id LEFT JOIN tww_od.channel ch ON ch.obj_id = ws.obj_id - WHERE ch.obj_id IS NULL AND (_all OR ws.obj_id = _obj_id OR ( NOT _all AND _obj_id is NULL AND ws.fk_main_wastewater_node IS NULL)) + WHERE ch.obj_id IS NULL AND (_all OR ((ws.obj_id = _obj_id OR (NOT _all AND _obj_id is NULL)) AND ws.fk_main_wastewater_node IS NULL)) ) ws_nodes WHERE ws.obj_id = ws_nodes.obj_id; END