Commit 6da4a66c authored by zav8's avatar zav8

merge switch cases

parent 5e4241fc
...@@ -152,7 +152,7 @@ func (o *rawSet) setFieldValue(ind reflect.Value, value interface{}) { ...@@ -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{}) { ...@@ -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 := indi.Scan(value)
if err == nil {
ind.Set(reflect.ValueOf(indi))
}
case sql.NullFloat64:
err := indi.Scan(value)
if err == nil {
ind.Set(reflect.ValueOf(indi))
} }
case sql.NullBool: 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)))
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment