From ad2a7ed68dcd53d34686b2ad1f3fa58928467428 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 24 May 2018 17:01:03 -0400 Subject: [PATCH] convert map definintion set to take only a json --- interface/map_def/srce_map_def_set.sql | 14 +++++++------- interface/map_def/test/mapdef.json | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/interface/map_def/srce_map_def_set.sql b/interface/map_def/srce_map_def_set.sql index 6ef417c..257fe5e 100644 --- a/interface/map_def/srce_map_def_set.sql +++ b/interface/map_def/srce_map_def_set.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION tps.srce_map_def_set(_srce text, _map text, _defn jsonb, _seq int) RETURNS jsonb +CREATE OR REPLACE FUNCTION tps.srce_map_def_set(_defn jsonb) RETURNS jsonb AS $f$ @@ -15,15 +15,15 @@ BEGIN INSERT INTO tps.map_rm SELECT - _srce - ,_map + _defn->>'srce' + ,_defn->>'name' ,_defn - ,_seq + ,_defn->>'sequence' ON CONFLICT ON CONSTRAINT map_rm_pk DO UPDATE SET - srce = _srce - ,target = _map + srce = _defn->>'srce' + ,target = _defn->>'name' ,regex = _defn - ,seq = _seq; + ,seq = _defn->>'sequence'; EXCEPTION WHEN OTHERS THEN diff --git a/interface/map_def/test/mapdef.json b/interface/map_def/test/mapdef.json index b085cee..7458cbc 100644 --- a/interface/map_def/test/mapdef.json +++ b/interface/map_def/test/mapdef.json @@ -1,4 +1,6 @@ { + "srce":"dcard", + "sequence":1, "defn": [ { "key": "{Description}",