From c05d72c87990c687a47a179ca917bcaa660888c1 Mon Sep 17 00:00:00 2001 From: Ivan Valkov Date: Mon, 3 Jul 2017 09:59:10 +0100 Subject: [PATCH] Updated the columnRegexp to include decimals --- scope.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scope.go b/scope.go index a21b7422..37559b4a 100644 --- a/scope.go +++ b/scope.go @@ -448,7 +448,7 @@ func (scope *Scope) callMethod(methodName string, reflectValue reflect.Value) { } var ( - columnRegexp = regexp.MustCompile("^[a-zA-Z]+(\\.[a-zA-Z]+)*$") // only match string like `name`, `users.name` + columnRegexp = regexp.MustCompile("^[a-zA-Z\\d]+(\\.[a-zA-Z\\d]+)*$") // only match string like `name`, `users.name` isNumberRegexp = regexp.MustCompile("^\\s*\\d+\\s*$") // match if string is number comparisonRegexp = regexp.MustCompile("(?i) (=|<>|>|<|LIKE|IS|IN) ") countingQueryRegexp = regexp.MustCompile("(?i)^count(.+)$") @@ -1143,7 +1143,7 @@ func (scope *Scope) addIndex(unique bool, indexName string, column ...string) { var columns []string for _, name := range column { - columns = append(columns, scope.Quote(name)) + columns = append(columns, scope.quoteIfPossible(name)) } sqlCreate := "CREATE INDEX"