mirror of
https://github.com/chartdb/chartdb.git
synced 2025-10-23 07:11:56 +00:00
Merge pull request #35 from chartdb/jf/escape_default_values
fix escape for column default values
This commit is contained in:
@@ -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 (
|
||||
|
@@ -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 (
|
||||
|
@@ -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')
|
||||
|
@@ -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
|
||||
|
@@ -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, '') +
|
||||
'"}')
|
||||
|
Reference in New Issue
Block a user