push constraint to seperate column

This commit is contained in:
Paul Trowbridge 2018-03-10 01:58:43 -05:00
parent 5dd2091752
commit 15349d2b1a
3 changed files with 22 additions and 22 deletions

View File

@ -49,7 +49,6 @@ CREATE TYPE tps."DCARD" AS (
COMMENT ON TYPE tps."DCARD" IS 'Discover Card'; COMMENT ON TYPE tps."DCARD" IS 'Discover Card';
-- --
-- Name: DMAPI; Type: TYPE; Schema: tps; Owner: - -- Name: DMAPI; Type: TYPE; Schema: tps; Owner: -
-- --
@ -59,7 +58,6 @@ CREATE TYPE tps."DMAPI" AS (
); );
-- --
-- Name: dcard; Type: TYPE; Schema: tps; Owner: - -- Name: dcard; Type: TYPE; Schema: tps; Owner: -
-- --
@ -521,7 +519,7 @@ BEGIN
FROM FROM
pending_keys k pending_keys k
INNER JOIN tps.trans t ON 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----------------------------------------------------------------------------------- -----------return unique keys that are not already in tps.trans-----------------------------------------------------------------------------------
@ -545,10 +543,11 @@ BEGIN
, inserted AS ( , inserted AS (
INSERT INTO INSERT INTO
tps.trans (srce, rec) tps.trans (srce, rec, ic)
SELECT SELECT
pl.srce pl.srce
,pl.rec ,pl.rec
,pl.json_key
FROM FROM
pending_list pl pending_list pl
INNER JOIN unmatched_keys u ON INNER JOIN unmatched_keys u ON
@ -1490,7 +1489,8 @@ CREATE TABLE tps.trans (
rec jsonb, rec jsonb,
parse jsonb, parse jsonb,
map 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'; 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: - -- Name: trans_id_seq; Type: SEQUENCE; Schema: tps; Owner: -
-- --

View File

@ -144,7 +144,7 @@ BEGIN
FROM FROM
pending_keys k pending_keys k
INNER JOIN tps.trans t ON 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----------------------------------------------------------------------------------- -----------return unique keys that are not already in tps.trans-----------------------------------------------------------------------------------
@ -168,10 +168,11 @@ BEGIN
, inserted AS ( , inserted AS (
INSERT INTO INSERT INTO
tps.trans (srce, rec) tps.trans (srce, rec, ic)
SELECT SELECT
pl.srce pl.srce
,pl.rec ,pl.rec
,pl.json_key
FROM FROM
pending_list pl pending_list pl
INNER JOIN unmatched_keys u ON INNER JOIN unmatched_keys u ON

View File

@ -99,13 +99,10 @@ BEGIN
,pending_list AS ( ,pending_list AS (
SELECT SELECT
jsonb_build_object( tps.jsonb_extract(
'input_constraint', row_to_json(i)::jsonb
tps.jsonb_extract( ,ext.text_array
row_to_json(i)::jsonb ) json_key,
,ext.text_array
)
) json_key,
row_to_json(i)::JSONB rec, row_to_json(i)::JSONB rec,
srce, srce,
--ae.rn, --ae.rn,
@ -136,7 +133,7 @@ BEGIN
FROM FROM
pending_keys k pending_keys k
INNER JOIN tps.trans t ON 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----------------------------------------------------------------------------------- -----------return unique keys that are not already in tps.trans-----------------------------------------------------------------------------------
@ -160,16 +157,11 @@ BEGIN
, inserted AS ( , inserted AS (
INSERT INTO INSERT INTO
/* tps.trans (srce, rec, ic)
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)
SELECT SELECT
pl.srce pl.srce
,pl.rec ,pl.rec
,pl.json_key
FROM FROM
pending_list pl pending_list pl
INNER JOIN unmatched_keys u ON INNER JOIN unmatched_keys u ON