Commit f6957209 authored by Alice Salsé's avatar Alice Salsé
Browse files

🐛 update nw objet attributes when exists

parent b2b98f55
......@@ -36,13 +36,12 @@ begin
INTO _geom_id;
-- >>> New row to jsonb <<<
_new:=jsonb_strip_nulls(row_to_json(new.*)::jsonb);
_new := _new -'id';
_new := _new || jsonb_build_object('level', _level);
_new := _new -'id' || jsonb_build_object('level', _level);
-- >>> Insert geom if not exist <<<
IF _geom_id is null then
-- Insert Geom
_geom_id := utils.fnc_insert_from_jsonb(TG_TABLE_SCHEMA||'.'||_nw_table, _new);
IF NOT EXISTS (SELECT FROM config.pipe_default_node
IF NOT EXISTS (SELECT FROM config.pipe_default_node
WHERE schemaname=TG_TABLE_SCHEMA and level=_level and active=False) THEN
-- ++ Insert defaults nodes/parts objects on pipe ++
for _def_node in EXECUTE FORMAT ('SELECT * FROM %1$I.pipe_default_node
......@@ -55,6 +54,10 @@ begin
PERFORM utils.fnc_insert_from_jsonb(TG_TABLE_SCHEMA||'.vw_'||_def_node.nodetable, _def_node_new);
END LOOP;
END IF;
ELSE
-- Update geom attributes
_new := _new - 'geom' || jsonb_build_object('id', _geom_id);
PERFORM utils.fnc_update_from_jsonb(TG_TABLE_SCHEMA||'.'||_nw_table, _new, jsonb_build_object('emptyjson', 'None'));
END IF;
-- >>> Control if object exist <<<
EXECUTE FORMAT (
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment