fix(sqlite): handle text timestamps in scan for cross-driver compatibility

The ncruces/go-sqlite3 driver does not always auto-convert TEXT columns
to time.Time. This caused scan errors on updated_at/created_at fields,
blocking witness startup.

Fix: Scan timestamps into sql.NullString and parse with parseTimeString()
helper that handles RFC3339Nano, RFC3339, and SQLite native formats.

Fixes: bd-4dqmy

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beads/crew/collins
2026-01-20 19:07:24 -08:00
committed by Steve Yegge
parent 90344b9939
commit 458fb7197a
4 changed files with 93 additions and 7 deletions

View File

@@ -1291,6 +1291,8 @@ type scanner interface {
// consistent scanning of issue rows.
func scanIssueRow(row scanner) (*types.Issue, error) {
var issue types.Issue
var createdAtStr sql.NullString // TEXT column - must parse manually for cross-driver compatibility
var updatedAtStr sql.NullString // TEXT column - must parse manually for cross-driver compatibility
var contentHash sql.NullString
var closedAt sql.NullTime
var estimatedMinutes sql.NullInt64
@@ -1336,7 +1338,7 @@ func scanIssueRow(row scanner) (*types.Issue, error) {
&issue.ID, &contentHash, &issue.Title, &issue.Description, &issue.Design,
&issue.AcceptanceCriteria, &issue.Notes, &issue.Status,
&issue.Priority, &issue.IssueType, &assignee, &estimatedMinutes,
&issue.CreatedAt, &issue.CreatedBy, &owner, &issue.UpdatedAt, &closedAt, &externalRef,
&createdAtStr, &issue.CreatedBy, &owner, &updatedAtStr, &closedAt, &externalRef,
&issue.CompactionLevel, &compactedAt, &compactedAtCommit, &originalSize, &sourceRepo, &closeReason,
&deletedAt, &deletedBy, &deleteReason, &originalType,
&sender, &wisp, &pinned, &isTemplate, &crystallizes,
@@ -1348,6 +1350,14 @@ func scanIssueRow(row scanner) (*types.Issue, error) {
return nil, fmt.Errorf("failed to scan issue: %w", err)
}
// Parse timestamp strings (TEXT columns require manual parsing)
if createdAtStr.Valid {
issue.CreatedAt = parseTimeString(createdAtStr.String)
}
if updatedAtStr.Valid {
issue.UpdatedAt = parseTimeString(updatedAtStr.String)
}
if contentHash.Valid {
issue.ContentHash = contentHash.String
}