Fix an issue with character escaping
This commit is contained in:
parent
7c2936832f
commit
369ed652ee
1 changed files with 10 additions and 2 deletions
|
|
@ -96,8 +96,16 @@ async function safeRemoveColumn(queryInterface, tableName, columnName) {
|
|||
if (info.unique) {
|
||||
def += ' UNIQUE';
|
||||
}
|
||||
if (info.defaultValue !== undefined) {
|
||||
def += ` DEFAULT ${info.defaultValue}`;
|
||||
if (
|
||||
info.defaultValue !== undefined &&
|
||||
info.defaultValue !== null
|
||||
) {
|
||||
// Properly quote string defaults
|
||||
const defaultVal =
|
||||
typeof info.defaultValue === 'string'
|
||||
? `'${info.defaultValue.replace(/'/g, "''")}'`
|
||||
: info.defaultValue;
|
||||
def += ` DEFAULT ${defaultVal}`;
|
||||
}
|
||||
|
||||
return def;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue