tps/srce_defn.pgsql

19 lines
365 B
Plaintext
Raw Normal View History

2017-10-25 00:42:22 -04:00
WITH
ext AS (
SELECT
srce
,defn->'unique_constraint'->>'fields'
,ARRAY(SELECT ae.e::text[] FROM jsonb_array_elements_text(defn->'unique_constraint'->'fields') ae(e)) txa
FROM
tps.srce
)
2017-10-25 00:42:22 -04:00
SELECT
t.srce
,jsonb_pretty(t.rec)
,jsonb_pretty(public.jsonb_extract(rec,txa))
2017-10-25 00:42:22 -04:00
FROM
tps.trans t
2017-10-25 00:42:22 -04:00
INNER JOIN ext ON
t.srce = ext.srce