Handle string as primary key

This commit is contained in:
Joris Minjat 2016-01-18 13:30:59 +00:00
parent 9739cb853c
commit 9d085dafdb

View File

@ -21,7 +21,11 @@ func (scope *Scope) buildWhereCondition(clause map[string]interface{}) (str stri
if regexp.MustCompile("^\\s*\\d+\\s*$").MatchString(value) {
return scope.primaryCondition(scope.AddToVars(value))
} else if value != "" {
str = fmt.Sprintf("(%v)", value)
if regexp.MustCompile("^[a-zA-Z0-9]+$").MatchString(value) {
return scope.primaryCondition(scope.AddToVars(value))
} else {
str = fmt.Sprintf("(%v)", value)
}
}
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, sql.NullInt64:
return scope.primaryCondition(scope.AddToVars(value))