From 39820d60515ce37717c4f100b51c590004e46a47 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Fri, 25 May 2018 10:23:43 -0400 Subject: [PATCH] test and modify building of view to be based on allj --- interface/source_maint/srce_build_view.sql | 4 +-- interface/source_maint/test/srce.json | 38 +++++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/interface/source_maint/srce_build_view.sql b/interface/source_maint/srce_build_view.sql index 735b69e..e23cdaa 100644 --- a/interface/source_maint/srce_build_view.sql +++ b/interface/source_maint/srce_build_view.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION tps.build_srce_view_sql(_srce text, _schema text) RETURNS TEXT +CREATE OR REPLACE FUNCTION tps.build_srce_view_sql(_srce text, _schema text) RETURNS TEXT AS $f$ DECLARE @@ -11,7 +11,7 @@ BEGIN _path:= ARRAY['schemas',_schema]::text[]; --_srce:= 'dcard'; SELECT - 'CREATE VIEW tpsv.'||_srce||'_'||_path[2]||' AS SELECT '||string_agg('(rec#>>'''||r.PATH::text||''')::'||r.type||' AS "'||r.column_name||'"',', ')||' FROM tps.trans WHERE srce = '''||_srce||'''' + 'CREATE VIEW tpsv.'||_srce||'_'||_path[2]||' AS SELECT '||string_agg('(allj#>>'''||r.PATH::text||''')::'||r.type||' AS "'||r.column_name||'"',', ')||' FROM tps.trans WHERE srce = '''||_srce||'''' INTO _sql FROM diff --git a/interface/source_maint/test/srce.json b/interface/source_maint/test/srce.json index 7c11996..b22fbf8 100644 --- a/interface/source_maint/test/srce.json +++ b/interface/source_maint/test/srce.json @@ -35,6 +35,42 @@ "column_name":"Category" } ], - "version2":[] + "mapped":[ + { + "path":"{Trans. Date}", + "type":"date", + "column_name":"Trans. Date" + }, + { + "path":"{Post Date}", + "type":"date", + "column_name":"Post Date" + }, + { + "path":"{Description}", + "type":"text", + "column_name":"Description" + }, + { + "path":"{Amount}", + "type":"numeric", + "column_name":"Amount" + }, + { + "path":"{Category}", + "type":"text", + "column_name":"Category" + }, + { + "path":"{party}", + "type":"text", + "column_name":"Party" + }, + { + "path":"{reason}", + "type":"text", + "column_name":"Reason" + } + ] } } \ No newline at end of file