mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 20:28:17 +08:00
auto update value of time field if given time value is zero for package gdb
This commit is contained in:
parent
9c5642f141
commit
91dd9e2bf9
@ -195,8 +195,20 @@ func ConvertDataForTableRecord(value interface{}) map[string]interface{} {
|
||||
}
|
||||
|
||||
case reflect.Struct:
|
||||
switch v.(type) {
|
||||
case time.Time, *time.Time, gtime.Time, *gtime.Time:
|
||||
switch r := v.(type) {
|
||||
// If the time is zero, it then updates it to nil,
|
||||
// which will insert/update the value to database as "null".
|
||||
case time.Time:
|
||||
if r.IsZero() {
|
||||
data[k] = nil
|
||||
}
|
||||
|
||||
case gtime.Time:
|
||||
if r.IsZero() {
|
||||
data[k] = nil
|
||||
}
|
||||
|
||||
case *time.Time, *gtime.Time:
|
||||
continue
|
||||
|
||||
case Counter, *Counter:
|
||||
|
Loading…
Reference in New Issue
Block a user