Merge pull request #35 from chartdb/jf/escape_default_values

fix escape for column default values
This commit is contained in:
Guy Ben-Aharon
2024-08-25 18:37:25 +03:00
committed by GitHub
5 changed files with 5 additions and 5 deletions

View File

@@ -70,7 +70,7 @@ export const mariaDBQuery = `WITH fk_info as (
END,
',"ordinal_position":"', cols.ordinal_position,
'","nullable":', IF(cols.is_nullable = 'YES', 'true', 'false'),
',"default":"', IFNULL(cols.column_default, ''),
',"default":"', IFNULL(REPLACE(cols.column_default, '"', '\\"'), ''),
'","collation":"', IFNULL(cols.collation_name, ''), '"}'
)))))
), indexes as (

View File

@@ -70,7 +70,7 @@ export const mySQLQuery = `WITH fk_info as (
END,
',"ordinal_position":"', cols.ordinal_position,
'","nullable":', IF(cols.is_nullable = 'YES', 'true', 'false'),
',"default":"', IFNULL(cols.column_default, ''),
',"default":"', IFNULL(REPLACE(cols.column_default, '"', '\\"'), ''),
'","collation":"', IFNULL(cols.collation_name, ''), '"}'
)))))
), indexes as (

View File

@@ -79,7 +79,7 @@ cols as (
ELSE 'null'
END,
',"nullable":', case when (cols.IS_NULLABLE = 'YES') then 'true' else 'false' end,
',"default":"', COALESCE(cols.column_default, ''),
',"default":"', COALESCE(replace(cols.column_default, '"', E'\\"'), ''),
'","collation":"', coalesce(cols.COLLATION_NAME, ''), '"}')), ',') as cols_metadata
from information_schema.columns cols
where cols.table_schema not in ('information_schema', 'pg_catalog')

View File

@@ -108,7 +108,7 @@ export const sqliteQuery = `WITH fk_info AS (
END
ELSE 'null'
END,
'default', COALESCE(p.dflt_value, '')
'default', COALESCE(REPLACE(p.dflt_value, '"', '\\"'), '')
)
) AS cols_metadata
FROM

View File

@@ -79,7 +79,7 @@ cols AS (
', "nullable": "' +
CASE WHEN cols.IS_NULLABLE = 'YES' THEN 'true' ELSE 'false' END +
'", "default": "' +
COALESCE(CAST(cols.COLUMN_DEFAULT AS NVARCHAR(MAX)), '') +
COALESCE(REPLACE(CAST(cols.COLUMN_DEFAULT AS NVARCHAR(MAX)), '"', '\\"'), '') +
'", "collation": "' +
COALESCE(cols.COLLATION_NAME, '') +
'"}')