1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-23 21:01:00 +03:00

feat: func isEmptyValue support time.Time (#3273)

* fix:func isEmptyValue support time.Time

* fix: Improve HSet unit tests

* feat: Improve HSet unit tests

* fix: isEmptyValue Struct only support time.Time

* test(hset): add empty custom struct test

---------

Co-authored-by: Guo Hui <gh7396@gmail.com>
Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
This commit is contained in:
Hui
2025-04-29 05:16:53 +08:00
committed by Nedyalko Dyakov
parent f9b0e70f4c
commit 46d4b20ee2
2 changed files with 71 additions and 4 deletions

View File

@ -155,6 +155,12 @@ func isEmptyValue(v reflect.Value) bool {
return v.Float() == 0
case reflect.Interface, reflect.Pointer:
return v.IsNil()
case reflect.Struct:
if v.Type() == reflect.TypeOf(time.Time{}) {
return v.IsZero()
}
// Only supports the struct time.Time,
// subsequent iterations will follow the func Scan support decoder.
}
return false
}