From ff3c23c9e9ec09ce5a3b2c64c5e65567df515355 Mon Sep 17 00:00:00 2001 From: Leon Maia Date: Fri, 7 Aug 2015 17:16:40 -0300 Subject: [PATCH] fixes #593 - Dont include quotes on dest table --- scope_private.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scope_private.go b/scope_private.go index 08da634e..f6f815d9 100644 --- a/scope_private.go +++ b/scope_private.go @@ -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) {