mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:30:54 +00:00
add support for field of type sql.NullXxx in rawSet.setFieldValue()
This commit is contained in:
parent
8152ade1b6
commit
5e4241fc87
@ -150,8 +150,10 @@ func (o *rawSet) setFieldValue(ind reflect.Value, value interface{}) {
|
||||
case reflect.Struct:
|
||||
if value == nil {
|
||||
ind.Set(reflect.Zero(ind.Type()))
|
||||
|
||||
} else if _, ok := ind.Interface().(time.Time); ok {
|
||||
return
|
||||
}
|
||||
switch indi := ind.Interface().(type) {
|
||||
case time.Time:
|
||||
var str string
|
||||
switch d := value.(type) {
|
||||
case time.Time:
|
||||
@ -178,6 +180,26 @@ func (o *rawSet) setFieldValue(ind reflect.Value, value interface{}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case sql.NullString:
|
||||
err := indi.Scan(value)
|
||||
if err == nil {
|
||||
ind.Set(reflect.ValueOf(indi))
|
||||
}
|
||||
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 := indi.Scan(value)
|
||||
if err == nil {
|
||||
ind.Set(reflect.ValueOf(indi))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user