Skip to content

Commit

Permalink
fix pg import query for comments cols+tbls (chartdb#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyfish authored Oct 19, 2024
1 parent 02a282b commit 637bfe9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/data/import-metadata/scripts/postgres-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ cols AS (
',"nullable":', CASE WHEN (cols.IS_NULLABLE = 'YES') THEN 'true' ELSE 'false' END,
',"default":"', COALESCE(replace(replace(cols.column_default, '"', '\\"'), '\\x', '\\\\x'), ''),
'","collation":"', COALESCE(cols.COLLATION_NAME, ''),
'","comment":"', COALESCE(dsc.description, ''), '"}')), ',') AS cols_metadata
'","comment":"', COALESCE(replace(replace(dsc.description, '"', '\\"'), '\\x', '\\\\x'), ''),
'"}')), ',') AS cols_metadata
FROM information_schema.columns cols
LEFT JOIN pg_catalog.pg_class c
ON c.relname = cols.table_name
Expand Down Expand Up @@ -204,7 +205,8 @@ cols AS (
FROM pg_stat_user_tables s
WHERE tbls.TABLE_SCHEMA = s.schemaname AND tbls.TABLE_NAME = s.relname),
0), ', "type":"', tbls.TABLE_TYPE, '",', '"engine":"",', '"collation":"",',
'"comment":"', COALESCE(dsc.description, ''), '"}'
'"comment":"', COALESCE(replace(replace(dsc.description, '"', '\\"'), '\\x', '\\\\x'), ''),
'"}'
)),
',') AS tbls_metadata
FROM information_schema.tables tbls
Expand Down

0 comments on commit 637bfe9

Please sign in to comment.