diff --git a/deploy/ubm_schema.sql b/deploy/ubm_schema.sql index 614639c..39c0d46 100644 --- a/deploy/ubm_schema.sql +++ b/deploy/ubm_schema.sql @@ -49,7 +49,6 @@ CREATE TYPE tps."DCARD" AS ( COMMENT ON TYPE tps."DCARD" IS 'Discover Card'; - -- -- Name: DMAPI; Type: TYPE; Schema: tps; Owner: - -- @@ -59,7 +58,6 @@ CREATE TYPE tps."DMAPI" AS ( ); - -- -- Name: dcard; Type: TYPE; Schema: tps; Owner: - -- @@ -521,7 +519,7 @@ BEGIN FROM pending_keys k INNER JOIN tps.trans t ON - t.rec @> k.json_key + t.ic = k.json_key ) -----------return unique keys that are not already in tps.trans----------------------------------------------------------------------------------- @@ -545,10 +543,11 @@ BEGIN , inserted AS ( INSERT INTO - tps.trans (srce, rec) + tps.trans (srce, rec, ic) SELECT pl.srce ,pl.rec + ,pl.json_key FROM pending_list pl INNER JOIN unmatched_keys u ON @@ -1490,7 +1489,8 @@ CREATE TABLE tps.trans ( rec jsonb, parse jsonb, map jsonb, - allj jsonb + allj jsonb, + ic jsonb ); @@ -1501,6 +1501,13 @@ CREATE TABLE tps.trans ( COMMENT ON TABLE tps.trans IS 'source records'; +-- +-- Name: COLUMN trans.ic; Type: COMMENT; Schema: tps; Owner: - +-- + +COMMENT ON COLUMN tps.trans.ic IS 'input constraint value'; + + -- -- Name: trans_id_seq; Type: SEQUENCE; Schema: tps; Owner: - -- diff --git a/functions/srce_import.sql b/functions/srce_import.sql index 9cb2a85..32026d9 100644 --- a/functions/srce_import.sql +++ b/functions/srce_import.sql @@ -144,7 +144,7 @@ BEGIN FROM pending_keys k INNER JOIN tps.trans t ON - t.rec @> k.json_key + t.ic = k.json_key ) -----------return unique keys that are not already in tps.trans----------------------------------------------------------------------------------- @@ -168,10 +168,11 @@ BEGIN , inserted AS ( INSERT INTO - tps.trans (srce, rec) + tps.trans (srce, rec, ic) SELECT pl.srce ,pl.rec + ,pl.json_key FROM pending_list pl INNER JOIN unmatched_keys u ON diff --git a/functions/srce_import_dev.sql b/functions/srce_import_dev.sql index 84d26a0..d08172f 100644 --- a/functions/srce_import_dev.sql +++ b/functions/srce_import_dev.sql @@ -99,13 +99,10 @@ BEGIN ,pending_list AS ( SELECT - jsonb_build_object( - 'input_constraint', - tps.jsonb_extract( - row_to_json(i)::jsonb - ,ext.text_array - ) - ) json_key, + tps.jsonb_extract( + row_to_json(i)::jsonb + ,ext.text_array + ) json_key, row_to_json(i)::JSONB rec, srce, --ae.rn, @@ -136,7 +133,7 @@ BEGIN FROM pending_keys k INNER JOIN tps.trans t ON - t.rec @> k.json_key + t.ic = k.json_key ) -----------return unique keys that are not already in tps.trans----------------------------------------------------------------------------------- @@ -160,16 +157,11 @@ BEGIN , inserted AS ( INSERT INTO - /* - need to insert the unique contraint somwhere at this point - * add to allj and make sure trigger does not overwrite - * add to rec - * add a new column - */ - tps.trans (srce, rec) + tps.trans (srce, rec, ic) SELECT pl.srce ,pl.rec + ,pl.json_key FROM pending_list pl INNER JOIN unmatched_keys u ON