diff --git a/scope_private.go b/scope_private.go index 5faebe2e..85f07e99 100644 --- a/scope_private.go +++ b/scope_private.go @@ -530,7 +530,7 @@ func (scope *Scope) addForeignKey(field string, dest string, onDelete string, on var table = scope.TableName() var keyName = fmt.Sprintf("%s_%s_foreign", table, field) var query = `ALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s ON DELETE %s ON UPDATE %s;` - scope.Raw(fmt.Sprintf(query, scope.QuotedTableName(), keyName, field, dest, onDelete, onUpdate)).Exec() + scope.Raw(fmt.Sprintf(query, scope.QuotedTableName(), scope.Quote(keyName), scope.Quote(field), scope.Quote(dest), onDelete, onUpdate)).Exec() } func (scope *Scope) removeIndex(indexName string) { @@ -548,7 +548,7 @@ func (scope *Scope) autoMigrate() *Scope { if !scope.Dialect().HasColumn(scope, tableName, field.DBName) { if field.IsNormal { sqlTag := scope.generateSqlTag(field) - scope.Raw(fmt.Sprintf("ALTER TABLE %v ADD %v %v;", quotedTableName, field.DBName, sqlTag)).Exec() + scope.Raw(fmt.Sprintf("ALTER TABLE %v ADD %v %v;", quotedTableName, scope.Quote(field.DBName), sqlTag)).Exec() } } scope.createJoinTable(field)