From aff228f95f1b285f832d4fdc97e3e8abc16441db Mon Sep 17 00:00:00 2001 From: Angela Xie Date: Fri, 14 Nov 2025 16:04:00 -0800 Subject: [PATCH] fix how zero time is written to storage --- go/store/val/codec.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/go/store/val/codec.go b/go/store/val/codec.go index 1ff0746de3..ad05c72a24 100644 --- a/go/store/val/codec.go +++ b/go/store/val/codec.go @@ -18,6 +18,7 @@ import ( "bytes" "context" "encoding/binary" + "github.com/dolthub/go-mysql-server/sql/types" "math" "math/big" "math/bits" @@ -577,10 +578,14 @@ func readDate(val []byte) (date time.Time) { func writeDate(buf []byte, val time.Time) { expectSize(buf, dateSize) - t := uint32(val.Year() << yearShift) - t += uint32(val.Month() << monthShift) - t += uint32(val.Day()) - writeUint32(buf, t) + if val.Equal(types.ZeroTime) { + writeUint32(buf, 0) + } else { + t := uint32(val.Year() << yearShift) + t += uint32(val.Month() << monthShift) + t += uint32(val.Day()) + writeUint32(buf, t) + } } func compareDate(l, r time.Time) int {