From 453d35bb87a041501a8e25eb4d8be761354e043c Mon Sep 17 00:00:00 2001 From: johnnyfish Date: Tue, 27 Aug 2024 13:19:45 +0300 Subject: [PATCH] fix for postgres - add escaping for imoprt query --- src/lib/data/import-metadata/scripts/postgres-script.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/data/import-metadata/scripts/postgres-script.ts b/src/lib/data/import-metadata/scripts/postgres-script.ts index a7a7f7b3..671b76f0 100644 --- a/src/lib/data/import-metadata/scripts/postgres-script.ts +++ b/src/lib/data/import-metadata/scripts/postgres-script.ts @@ -24,8 +24,8 @@ export const postgresQuery = `WITH fk_info AS ( ), pk_info AS ( SELECT array_to_string(array_agg(CONCAT('{"schema":"', schema_name, '"', ',"table":"', pk_table, '"', - ',"column":"', pk_column, '"', - ',"pk_def":"', pk_def, + ',"column":"', replace(pk_column, '"', ''), '"', + ',"pk_def":"', replace(pk_def, '"', ''), '"}')), ',') as pk_metadata FROM ( SELECT @@ -79,7 +79,7 @@ cols as ( ELSE 'null' END, ',"nullable":', case when (cols.IS_NULLABLE = 'YES') then 'true' else 'false' end, - ',"default":"', COALESCE(replace(cols.column_default, '"', E'\\"'), ''), + ',"default":"', COALESCE(replace(replace(cols.column_default, '"', E'\\"'), '\\x', '\\\\x'), ''), '","collation":"', coalesce(cols.COLLATION_NAME, ''), '"}')), ',') as cols_metadata from information_schema.columns cols where cols.table_schema not in ('information_schema', 'pg_catalog')