mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 23:40:56 +00:00
merge switch cases
This commit is contained in:
parent
5e4241fc87
commit
6da4a66c20
@ -152,7 +152,7 @@ func (o *rawSet) setFieldValue(ind reflect.Value, value interface{}) {
|
|||||||
ind.Set(reflect.Zero(ind.Type()))
|
ind.Set(reflect.Zero(ind.Type()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch indi := ind.Interface().(type) {
|
switch ind.Interface().(type) {
|
||||||
case time.Time:
|
case time.Time:
|
||||||
var str string
|
var str string
|
||||||
switch d := value.(type) {
|
switch d := value.(type) {
|
||||||
@ -180,25 +180,15 @@ func (o *rawSet) setFieldValue(ind reflect.Value, value interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case sql.NullString:
|
case sql.NullString, sql.NullInt64, sql.NullFloat64, sql.NullBool:
|
||||||
err := indi.Scan(value)
|
indi := reflect.New(ind.Type()).Interface()
|
||||||
if err == nil {
|
sc, ok := indi.(sql.Scanner)
|
||||||
ind.Set(reflect.ValueOf(indi))
|
if !ok {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
case sql.NullInt64:
|
err := sc.Scan(value)
|
||||||
err := indi.Scan(value)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ind.Set(reflect.ValueOf(indi))
|
ind.Set(reflect.Indirect(reflect.ValueOf(sc)))
|
||||||
}
|
|
||||||
case sql.NullFloat64:
|
|
||||||
err := indi.Scan(value)
|
|
||||||
if err == nil {
|
|
||||||
ind.Set(reflect.ValueOf(indi))
|
|
||||||
}
|
|
||||||
case sql.NullBool:
|
|
||||||
err := indi.Scan(value)
|
|
||||||
if err == nil {
|
|
||||||
ind.Set(reflect.ValueOf(indi))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user