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

@@ -8,6 +8,11 @@ export const getMySQLQuery = (
const databaseEdition: DatabaseEdition | undefined =
options.databaseEdition;
const withExtras = false;
const withDefault = `IFNULL(REPLACE(REPLACE(cols.column_default, '\\\\', ''), '"', 'ֿֿֿ\\"'), '')`;
const withoutDefault = `""`;
const newMySQLQuery = `WITH fk_info as (
(SELECT (@fk_info:=NULL),
(SELECT (0)
@@ -86,7 +91,7 @@ export const getMySQLQuery = (
END,
',"ordinal_position":', cols.ordinal_position,
',"nullable":', IF(cols.is_nullable = 'YES', 'true', 'false'),
',"default":"', IFNULL(REPLACE(REPLACE(cols.column_default, '\\\\', ''), '"', 'ֿֿֿ\\"'), ''),
',"default":"', ${withExtras ? withDefault : withoutDefault},
'","collation":"', IFNULL(cols.collation_name, ''), '"}'
)))))
), indexes as (
@@ -211,7 +216,7 @@ export const getMySQLQuery = (
',"scale":', IFNULL(cols.numeric_scale, 'null'), '}'), 'null'),
',"ordinal_position":', cols.ordinal_position,
',"nullable":', IF(cols.is_nullable = 'YES', 'true', 'false'),
',"default":"', IFNULL(REPLACE(REPLACE(cols.column_default, '\\\\', ''), '"', '\\"'), ''),
',"default":"', ${withExtras ? withDefault : withoutDefault},
'","collation":"', IFNULL(cols.collation_name, ''), '"}')
) FROM (
SELECT cols.table_schema,