fix(import-database): remove the default fetch from import database (#718)

* fix(import-database): remove the default fetch from import database

* fix(import-default): keep the option to fetch extras like default and comments
This commit is contained in:
Jonathan Fishner
2025-05-28 10:10:33 +03:00
committed by GitHub
parent 5b9d2bd1e3
commit 0d11b0c55a
8 changed files with 40 additions and 15 deletions

View File

@@ -55,6 +55,14 @@ export const getPostgresQuery = (
AND views.schemaname !~ '^(timescaledb_|_timescaledb_)'
`;
const withExtras = false;
const withDefault = `COALESCE(replace(replace(cols.column_default, '"', '\\"'), '\\x', '\\\\x'), '')`;
const withoutDefault = `null`;
const withComments = `COALESCE(replace(replace(dsc.description, '"', '\\"'), '\\x', '\\\\x'), '')`;
const withoutComments = `null`;
// Define the base query
const query = `${`/* ${databaseEdition ? databaseEditionToLabelMap[databaseEdition] : 'PostgreSQL'} edition */`}
WITH fk_info${databaseEdition ? '_' + databaseEdition : ''} AS (
@@ -175,9 +183,9 @@ cols AS (
ELSE 'null'
END,
',"nullable":', CASE WHEN (cols.IS_NULLABLE = 'YES') THEN 'true' ELSE 'false' END,
',"default":"', COALESCE(replace(replace(cols.column_default, '"', '\\"'), '\\x', '\\\\x'), ''),
',"default":"', ${withExtras ? withDefault : withoutDefault},
'","collation":"', COALESCE(cols.COLLATION_NAME, ''),
'","comment":"', COALESCE(replace(replace(dsc.description, '"', '\\"'), '\\x', '\\\\x'), ''),
'","comment":"', ${withExtras ? withComments : withoutComments},
'"}')), ',') AS cols_metadata
FROM information_schema.columns cols
LEFT JOIN pg_catalog.pg_class c