2
0

Date text encoding includes leading zero for month and day

e.g. 2000-01-01 instead of 2000-1-1. PostgreSQL accepted it without
zeroes but our text decoder didn't. This caused a problem when we needed
to take a value and encode to text so something else could parse it as
if it had come from the PostgreSQL server in text format. e.g.
database/sql compatibility.
This commit is contained in:
Jack Christensen
2022-10-01 10:41:40 -05:00
parent 63ae730fe8
commit 89f69aaea9
+6
View File
@@ -195,8 +195,14 @@ func (encodePlanDateCodecText) Encode(value any, buf []byte) (newBuf []byte, err
buf = strconv.AppendInt(buf, int64(year), 10)
buf = append(buf, '-')
if date.Time.Month() < 10 {
buf = append(buf, '0')
}
buf = strconv.AppendInt(buf, int64(date.Time.Month()), 10)
buf = append(buf, '-')
if date.Time.Day() < 10 {
buf = append(buf, '0')
}
buf = strconv.AppendInt(buf, int64(date.Time.Day()), 10)
if bc {