test and modify building of view to be based on allj

This commit is contained in:
Paul Trowbridge 2018-05-25 10:23:43 -04:00
parent cdba942e9e
commit 39820d6051
2 changed files with 39 additions and 3 deletions

View File

@ -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 AS
$f$ $f$
DECLARE DECLARE
@ -11,7 +11,7 @@ BEGIN
_path:= ARRAY['schemas',_schema]::text[]; _path:= ARRAY['schemas',_schema]::text[];
--_srce:= 'dcard'; --_srce:= 'dcard';
SELECT 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 INTO
_sql _sql
FROM FROM

View File

@ -35,6 +35,42 @@
"column_name":"Category" "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"
}
]
} }
} }