Reject Timestamp years outside 0000-9999 in Value
CI / ci (push) Successful in 48s
CI / ci (pull_request) Successful in 49s
Independent review Codex gpt-6-sol high: CHANGES_REQUIRED (1 medium)

The four-digit stored form cannot represent them, so Value would emit
TEXT that Scan rejects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 08:45:47 -04:00
co-authored by Claude Opus 5.5
parent 5304887ce9
commit e99ddec433
2 changed files with 14 additions and 1 deletions
+5 -1
View File
@@ -29,11 +29,15 @@ func (t Timestamp) String() string {
return t.UTC().Format(timestampLayout)
}
// Value implements driver.Valuer. The zero Timestamp is an error.
// Value implements driver.Valuer. The zero Timestamp is an error, as is a UTC
// year outside 0000–9999, which the four-digit stored form cannot represent.
func (t Timestamp) Value() (driver.Value, error) {
if t.IsZero() {
return nil, errors.New("store: zero Timestamp")
}
if y := t.UTC().Year(); y < 0 || y > 9999 {
return nil, fmt.Errorf("store: Timestamp year %d outside 0000-9999", y)
}
return t.String(), nil
}