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';
--
-- 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: -
--

View File

@ -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

View File

@ -99,12 +99,9 @@ BEGIN
,pending_list AS (
SELECT
jsonb_build_object(
'input_constraint',
tps.jsonb_extract(
row_to_json(i)::jsonb
,ext.text_array
)
) json_key,
row_to_json(i)::JSONB rec,
srce,
@ -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