From 4c3daade4c1da8b00f4b433a8386963474d6ddfe Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Tue, 21 Jul 2015 10:12:31 +0800 Subject: [PATCH] Don't quote column if it is not only column name when create index --- scope_private.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scope_private.go b/scope_private.go index 85f07e99..edd0dbe9 100644 --- a/scope_private.go +++ b/scope_private.go @@ -515,7 +515,11 @@ func (scope *Scope) addIndex(unique bool, indexName string, column ...string) { var columns []string for _, name := range column { - columns = append(columns, scope.Quote(name)) + if regexp.MustCompile("^[a-zA-Z]+$").MatchString(name) { + columns = append(columns, scope.Quote(name)) + } else { + columns = append(columns, name) + } } sqlCreate := "CREATE INDEX"