Use []byte as condtions
This commit is contained in:
parent
1b1dbc0fab
commit
52ac75a29a
@ -48,12 +48,16 @@ func (scope *Scope) buildWhereCondition(clause map[string]interface{}) (str stri
|
|||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
switch reflect.ValueOf(arg).Kind() {
|
switch reflect.ValueOf(arg).Kind() {
|
||||||
case reflect.Slice: // For where("id in (?)", []int64{1,2})
|
case reflect.Slice: // For where("id in (?)", []int64{1,2})
|
||||||
|
if bytes, ok := arg.([]byte); ok {
|
||||||
|
scope.AddToVars(bytes)
|
||||||
|
} else {
|
||||||
values := reflect.ValueOf(arg)
|
values := reflect.ValueOf(arg)
|
||||||
var tempMarks []string
|
var tempMarks []string
|
||||||
for i := 0; i < values.Len(); i++ {
|
for i := 0; i < values.Len(); i++ {
|
||||||
tempMarks = append(tempMarks, scope.AddToVars(values.Index(i).Interface()))
|
tempMarks = append(tempMarks, scope.AddToVars(values.Index(i).Interface()))
|
||||||
}
|
}
|
||||||
str = strings.Replace(str, "?", strings.Join(tempMarks, ","), 1)
|
str = strings.Replace(str, "?", strings.Join(tempMarks, ","), 1)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
if valuer, ok := interface{}(arg).(driver.Valuer); ok {
|
if valuer, ok := interface{}(arg).(driver.Valuer); ok {
|
||||||
arg, _ = valuer.Value()
|
arg, _ = valuer.Value()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user