mirror of https://github.com/go-gorm/gorm.git
Allow use number as column name (#1517)
* Updated scope.go to always quote when adding index I am using numbers for column names (to be compatible with protobuf) and adding unique index to them does not work since they are not quoted. I do not see a reason to check if the column name is a string in order to quote it. Correct me if I am wrong. * Updated the columnRegexp to include decimals * Update scope.go
This commit is contained in:
parent
d510c7e4b8
commit
2a1463811e
4
scope.go
4
scope.go
|
@ -448,8 +448,8 @@ 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`
|
||||
isNumberRegexp = regexp.MustCompile("^\\s*\\d+\\s*$") // match if string is number
|
||||
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(.+)$")
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue