Skip to content

Commit c0e9e12

Browse files
authored
Merge pull request #21 from kenshin579/feat/#20-not
[#20] not to caching even if the updatedAt has a default time value
2 parents 4731aac + 3d44e21 commit c0e9e12

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func isMapEmpty(m map[string]any) bool {
331331
for _, v := range m {
332332
switch val := v.(type) {
333333
case string:
334-
if val != "" {
334+
if val != "" && val != "0001-01-01T00:00:00Z" {
335335
return false
336336
}
337337
case int:

cache_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ func Test_isAllFieldsEmpty(t *testing.T) {
292292
City string `json:"city"`
293293
Zip int `json:"zip"`
294294
} `json:"address"`
295+
UpdatedAt time.Time `json:"updatedAt"`
295296
}
296297

297298
p1 := person{
@@ -323,6 +324,7 @@ func Test_isAllFieldsEmpty(t *testing.T) {
323324
assert.False(t, isAllFieldsEmpty([]byte(`{"a":"","b":"b","c":0}`)))
324325
assert.True(t, isAllFieldsEmpty([]byte(`{"a":"","b":"","c":0}`)))
325326
assert.True(t, isAllFieldsEmpty([]byte(`{"a":"","b":"","c":0.0}`)))
327+
assert.True(t, isAllFieldsEmpty([]byte(`{"a":"","b":"","c":0.0,"updatedAt":"0001-01-01T00:00:00Z"}`)))
326328
}
327329

328330
func Test_isIncludePaths(t *testing.T) {

0 commit comments

Comments
 (0)