mirror of https://github.com/go-gorm/gorm.git
fixes #593 - Dont include quotes on dest table
This commit is contained in:
parent
ab1832b9a5
commit
ff3c23c9e9
|
@ -575,7 +575,7 @@ func (scope *Scope) addForeignKey(field string, dest string, onDelete string, on
|
|||
var keyName = fmt.Sprintf("%s_%s_%s_foreign", table, field, regexp.MustCompile("[^a-zA-Z]").ReplaceAllString(dest, "_"))
|
||||
keyName = regexp.MustCompile("_+").ReplaceAllString(keyName, "_")
|
||||
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(), scope.QuoteIfPossible(keyName), scope.QuoteIfPossible(field), scope.QuoteIfPossible(dest), onDelete, onUpdate)).Exec()
|
||||
scope.Raw(fmt.Sprintf(query, scope.QuotedTableName(), scope.QuoteIfPossible(keyName), scope.QuoteIfPossible(field), dest, onDelete, onUpdate)).Exec()
|
||||
}
|
||||
|
||||
func (scope *Scope) removeIndex(indexName string) {
|
||||
|
|
Loading…
Reference in New Issue