fix(mysql): preserve empty string column defaults
This commit is contained in:
1 parent
a737b31e0e
commit
f25759dcf0
2 files changed
+115
-1
No files matched your search
@@ -632,7 +632,12 @@ function stripSqlServerDefaultOuterParens(defaultValue: string): string {
|
||||
}
|
||||
|
||||
function columnDefaultForEditor(column: ColumnInfo, databaseType?: DatabaseType): string {
|
||||
const defaultValue = column.column_default ?? "";
|
||||
if (column.column_default === null) return "";
|
||||
const defaultValue = column.column_default;
|
||||
if (databaseType === "mysql" && defaultValue === "" && isMysqlCharacterDataType(column.data_type)) {
|
||||
// MySQL metadata uses an empty string for DEFAULT '', so keep it distinct from no default.
|
||||
return "''";
|
||||
}
|
||||
if (databaseType === "postgres") return stripPostgresStringDefaultCast(defaultValue, column.data_type);
|
||||
if (databaseType === "sqlserver") return stripSqlServerDefaultOuterParens(defaultValue);
|
||||
return defaultValue;
|
||||
|
||||
Reference in new issue
Block a user