Skip to content

Commit

Permalink
fix(trg_edit): bug fix when deleting features with null addfield values
Browse files Browse the repository at this point in the history
  • Loading branch information
mguzman14 committed Aug 13, 2024
1 parent 7e5bff4 commit 38cd989
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 39 deletions.
10 changes: 5 additions & 5 deletions ud/ftrg/ud_gw_trg_edit_arc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ v_auto_sander boolean;
v_seq_name text;
v_seq_code text;
v_code_prefix text;
v_arc_id text;

BEGIN
EXECUTE 'SET search_path TO '||quote_literal(TG_TABLE_SCHEMA)||', public';
Expand Down Expand Up @@ -767,11 +768,10 @@ BEGIN
UPDATE config_param_user SET value = v_force_delete WHERE parameter = 'plan_psector_force_delete' and cur_user = current_user;

-- Delete childtable addfields (after or before deletion of arc, doesn't matter)
FOR v_addfields IN SELECT * FROM sys_addfields
WHERE (cat_feature_id = v_customfeature OR cat_feature_id is null) AND active IS TRUE AND iseditable IS TRUE
LOOP
EXECUTE 'DELETE FROM man_arc_'||lower(v_addfields.cat_feature_id)||' WHERE arc_id = OLD.arc_id';
END LOOP;
v_customfeature = old.arc_type;
v_arc_id = old.arc_id;

EXECUTE 'DELETE FROM man_arc_'||lower(v_customfeature)||' WHERE arc_id = '||quote_literal(v_arc_id)||'';

RETURN NULL;

Expand Down
10 changes: 5 additions & 5 deletions ud/ftrg/ud_gw_trg_edit_connec.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ v_trace_featuregeom boolean;
v_seq_name text;
v_seq_code text;
v_code_prefix text;
v_connec_id text;

BEGIN

Expand Down Expand Up @@ -812,11 +813,10 @@ BEGIN
UPDATE config_param_user SET value = v_force_delete WHERE parameter = 'plan_psector_force_delete' and cur_user = current_user;

-- Delete childtable addfields (after or before deletion of connec, doesn't matter)
FOR v_addfields IN SELECT * FROM sys_addfields
WHERE (cat_feature_id = v_customfeature OR cat_feature_id is null) AND active IS TRUE AND iseditable IS TRUE
LOOP
EXECUTE 'DELETE FROM man_connec_'||lower(v_addfields.cat_feature_id)||' WHERE connec_id = OLD.connec_id';
END LOOP;
v_customfeature = old.connec_type;
v_connec_id = old.connec_id;

EXECUTE 'DELETE FROM man_connec_'||lower(v_customfeature)||' WHERE connec_id = '||quote_literal(v_connec_id)||'';

-- delete links
FOR v_record_link IN SELECT * FROM link WHERE feature_type='CONNEC' AND feature_id=OLD.connec_id
Expand Down
10 changes: 5 additions & 5 deletions ud/ftrg/ud_gw_trg_edit_gully.sql
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ v_trace_featuregeom boolean;
v_seq_name text;
v_seq_code text;
v_code_prefix text;
v_gully_id text;

BEGIN

Expand Down Expand Up @@ -975,11 +976,10 @@ BEGIN
UPDATE config_param_user SET value = v_force_delete WHERE parameter = 'plan_psector_force_delete' and cur_user = current_user;

-- Delete childtable addfields (after or before deletion of gully, doesn't matter)
FOR v_addfields IN SELECT * FROM sys_addfields
WHERE (cat_feature_id = v_customfeature OR cat_feature_id is null) AND active IS TRUE AND iseditable IS TRUE
LOOP
EXECUTE 'DELETE FROM man_gully_'||lower(v_addfields.cat_feature_id)||' WHERE gully_id = OLD.gully_id';
END LOOP;
v_customfeature = old.gully_type;
v_gully_id = old.gully_id;

EXECUTE 'DELETE FROM man_gully_'||lower(v_customfeature)||' WHERE gully_id = '||quote_literal(v_gully_id)||'';

-- delete links
FOR v_record_link IN SELECT * FROM link WHERE feature_type='GULLY' AND feature_id=OLD.gully_id
Expand Down
10 changes: 5 additions & 5 deletions ud/ftrg/ud_gw_trg_edit_node.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ v_auto_streetvalues_field text;
v_man_view text;
v_input json;
v_auto_sander boolean;
v_node_id text;

BEGIN

Expand Down Expand Up @@ -1002,11 +1003,10 @@ BEGIN
UPDATE config_param_user SET value = v_force_delete WHERE parameter = 'plan_psector_force_delete' and cur_user = current_user;

-- Delete childtable addfields (after or before deletion of node, doesn't matter)
FOR v_addfields IN SELECT * FROM sys_addfields
WHERE (cat_feature_id = v_customfeature OR cat_feature_id is null) AND active IS TRUE AND iseditable IS TRUE
LOOP
EXECUTE 'DELETE FROM man_node_'||lower(v_addfields.cat_feature_id)||' WHERE node_id = OLD.node_id';
END LOOP;
v_customfeature = old.node_type;
v_node_id = old.node_id;

EXECUTE 'DELETE FROM man_node_'||lower(v_customfeature)||' WHERE node_id = '||quote_literal(v_node_id)||'';

RETURN NULL;
END IF;
Expand Down
17 changes: 9 additions & 8 deletions ws/ftrg/ws_gw_trg_edit_arc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ v_psector integer;
v_seq_name text;
v_seq_code text;
v_code_prefix text;
v_arc_id text;

BEGIN

Expand Down Expand Up @@ -666,14 +667,14 @@ BEGIN
-- restore plan_psector_force_delete
UPDATE config_param_user SET value = v_force_delete WHERE parameter = 'plan_psector_force_delete' and cur_user = current_user;

-- Delete childtable addfields (after or before deletion of arc, doesn't matter)
FOR v_addfields IN SELECT * FROM sys_addfields
WHERE (cat_feature_id = v_customfeature OR cat_feature_id is null) AND active IS TRUE AND iseditable IS TRUE
LOOP
EXECUTE 'DELETE FROM man_arc_'||lower(v_addfields.cat_feature_id)||' WHERE arc_id = OLD.arc_id';
END LOOP;

-- delete from arc_add table
-- Delete childtable addfields (after or before deletion of node, doesn't matter)
v_customfeature = old.arc_type;
v_arc_id = old.arc_id;
EXECUTE 'DELETE FROM man_arc_'||lower(v_customfeature)||' WHERE arc_id = '||quote_literal(v_arc_id)||'';

-- delete from arc_add table
DELETE FROM arc_add WHERE arc_id = OLD.arc_id;

RETURN NULL;
Expand Down
13 changes: 7 additions & 6 deletions ws/ftrg/ws_gw_trg_edit_connec.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ v_trace_featuregeom boolean;
v_seq_name text;
v_seq_code text;
v_code_prefix text;
v_connec_id text;

BEGIN

Expand Down Expand Up @@ -945,12 +946,12 @@ BEGIN

END LOOP;

-- Delete childtable addfields (after or before deletion of connec, doesn't matter)
FOR v_addfields IN SELECT * FROM sys_addfields
WHERE (cat_feature_id = v_customfeature OR cat_feature_id is null) AND active IS TRUE AND iseditable IS TRUE
LOOP
EXECUTE 'DELETE FROM man_connec_'||lower(v_addfields.cat_feature_id)||' WHERE connec_id = OLD.connec_id';
END LOOP;
-- Delete childtable addfields (after or before deletion of node, doesn't matter)
v_customfeature = old.connec_type;
v_connec_id = old.connec_id;
EXECUTE 'DELETE FROM man_connec_'||lower(v_customfeature)||' WHERE connec_id = '||quote_literal(v_connec_id)||'';

RETURN NULL;

Expand Down
11 changes: 6 additions & 5 deletions ws/ftrg/ws_gw_trg_edit_node.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1092,11 +1092,12 @@ BEGIN
DELETE FROM config_graph_mincut WHERE node_id=OLD.node_id;

-- Delete childtable addfields (after or before deletion of node, doesn't matter)
FOR v_addfields IN SELECT * FROM sys_addfields
WHERE (cat_feature_id = v_customfeature OR cat_feature_id is null) AND active IS TRUE AND iseditable IS TRUE
LOOP
EXECUTE 'DELETE FROM man_node_'||lower(v_addfields.cat_feature_id)||' WHERE node_id = OLD.node_id';
END LOOP;

v_customfeature = old.node_type;
v_node_id = old.node_id;

EXECUTE 'DELETE FROM man_node_'||lower(v_customfeature)||' WHERE node_id = '||quote_literal(v_node_id)||'';


-- delete from node_add table
DELETE FROM node_add WHERE node_id = OLD.node_id;
Expand Down

0 comments on commit 38cd989

Please sign in to comment.