Don't quote column if it is not only column name when create index

This commit is contained in:
Jinzhu 2015-07-21 10:12:31 +08:00
parent 5663048f13
commit 4c3daade4c
1 changed files with 5 additions and 1 deletions

View File

@ -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"