增加自定义类型实现FromDB,ToDB方法,使用指针类型添加/更新时使用空更新,不使用默认值
This commit is contained in:
parent
bc8bb23ad0
commit
bb8b2f6dc8
|
@ -558,7 +558,10 @@ func (session *Session) value2Interface(col *core.Column, fieldValue reflect.Val
|
|||
if col.SQLType.IsBlob() {
|
||||
return data, nil
|
||||
}
|
||||
return string(data), nil
|
||||
if len(data) > 0 {
|
||||
return string(data), nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
fieldType := fieldValue.Type()
|
||||
|
|
|
@ -330,6 +330,11 @@ func (statement *Statement) buildUpdates(bean interface{},
|
|||
if err != nil {
|
||||
engine.logger.Error(err)
|
||||
} else {
|
||||
if fieldType.Kind() == reflect.Ptr && len(data) == 0 {
|
||||
args = append(args, nil)
|
||||
colNames = append(colNames, fmt.Sprintf("%v=?", engine.Quote(col.Name)))
|
||||
continue
|
||||
}
|
||||
val = data
|
||||
}
|
||||
goto APPEND
|
||||
|
|
Loading…
Reference in New Issue