mirror of
https://github.com/chartdb/chartdb.git
synced 2025-11-06 06:53:34 +00:00
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:
@@ -1,5 +1,10 @@
|
||||
import { DatabaseEdition } from '@/lib/domain/database-edition';
|
||||
|
||||
const withExtras = false;
|
||||
|
||||
const withDefault = `'"' + STRING_ESCAPE(COALESCE(REPLACE(CAST(cols.COLUMN_DEFAULT AS NVARCHAR(MAX)), '"', '\\"'), ''), 'json') + '"'`;
|
||||
const withoutDefault = `'""'`;
|
||||
|
||||
const sqlServerQuery = `${`/* SQL Server 2017 and above edition (14.0, 15.0, 16.0, 17.0)*/`}
|
||||
WITH fk_info AS (
|
||||
SELECT
|
||||
@@ -81,8 +86,7 @@ cols AS (
|
||||
ELSE 'null'
|
||||
END +
|
||||
', "nullable": ' + CASE WHEN cols.IS_NULLABLE = 'YES' THEN 'true' ELSE 'false' END +
|
||||
', "default": ' +
|
||||
'"' + STRING_ESCAPE(COALESCE(REPLACE(CAST(cols.COLUMN_DEFAULT AS NVARCHAR(MAX)), '"', '\\"'), ''), 'json') + '"' +
|
||||
', "default": ' + ${withExtras ? withDefault : withoutDefault} +
|
||||
', "collation": ' + CASE
|
||||
WHEN cols.COLLATION_NAME IS NULL THEN 'null'
|
||||
ELSE '"' + STRING_ESCAPE(cols.COLLATION_NAME, 'json') + '"'
|
||||
@@ -275,8 +279,7 @@ cols AS (
|
||||
ELSE 'null'
|
||||
END +
|
||||
', "nullable": ' + CASE WHEN cols.IS_NULLABLE = 'YES' THEN 'true' ELSE 'false' END +
|
||||
', "default": ' +
|
||||
'"' + STRING_ESCAPE(COALESCE(REPLACE(CAST(cols.COLUMN_DEFAULT AS NVARCHAR(MAX)), '"', '\\"'), ''), 'json') + '"' +
|
||||
', "default": ' + ${withExtras ? withDefault : withoutDefault} +
|
||||
', "collation": ' +
|
||||
CASE
|
||||
WHEN cols.COLLATION_NAME IS NULL THEN 'null'
|
||||
|
||||
Reference in New Issue
Block a user