Cas't string default value NULL to null

Fixes #2924
This commit is contained in:
rijkvanzanten
2020-11-27 20:53:51 -05:00
parent bf45a08c37
commit cc2b18d711

View File

@@ -9,12 +9,14 @@ export default function getDefaultValue(
let defaultValue = column.default_value || null;
if (defaultValue === null) return null;
if (defaultValue === 'null') return null;
if (defaultValue === 'NULL') return null;
// Check if the default is wrapped in an extra pair of quotes, this happens in SQLite
if (
typeof defaultValue === 'string' &&
defaultValue.startsWith(`'`) &&
defaultValue.endsWith(`'`)
((defaultValue.startsWith(`'`) && defaultValue.endsWith(`'`)) ||
(defaultValue.startsWith(`"`) && defaultValue.endsWith(`"`)))
) {
defaultValue = defaultValue.slice(1, -1);
}