fix: scan SQLite text timestamps in channel summary query
sql.NullTime cannot scan SQLite's text-format timestamps from modernc.org/sqlite. Switch to sql.NullString with manual time.Parse. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
fe8928a7fc
commit
68b7d946b3
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ChannelStore defines the storage interface for channel operations.
|
||||
@@ -394,12 +395,16 @@ func (s *SQLiteChannelStore) GetChannelSummaries(ctx context.Context, agentName
|
||||
var summaries []ChannelSummary
|
||||
for rows.Next() {
|
||||
var cs ChannelSummary
|
||||
var lastMsg sql.NullTime
|
||||
var lastMsg sql.NullString
|
||||
if err := rows.Scan(&cs.ID, &cs.Name, &cs.UnreadCount, &lastMsg); err != nil {
|
||||
return nil, fmt.Errorf("scan channel summary: %w", err)
|
||||
}
|
||||
if lastMsg.Valid {
|
||||
cs.LastMessageAt = &lastMsg.Time
|
||||
if t, err := time.Parse("2006-01-02T15:04:05Z", lastMsg.String); err == nil {
|
||||
cs.LastMessageAt = &t
|
||||
} else if t, err := time.Parse("2006-01-02 15:04:05", lastMsg.String); err == nil {
|
||||
cs.LastMessageAt = &t
|
||||
}
|
||||
}
|
||||
summaries = append(summaries, cs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user