fix: replace sql.NullTime with string scan for MAX() aggregate queries
Go 1.26 changed NullTime.Scan to delegate to convertAssign, which has no string->time.Time conversion path. The modernc.org/sqlite driver returns raw strings for aggregate expressions like MAX(last_used_at), causing silent scan failures that made all clients/providers show 'Never' for last used. Fixes by scanning into a string and parsing with time.Parse.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -47,13 +46,14 @@ func (s *Server) handleGetClients(c *gin.Context) {
|
||||
desc = *cl.Description
|
||||
}
|
||||
|
||||
var lastUsedTime sql.NullTime
|
||||
_ = s.database.Get(&lastUsedTime, "SELECT MAX(last_used_at) FROM client_tokens WHERE client_id = ?", cl.ClientID)
|
||||
var lastUsedStr string
|
||||
_ = s.database.Get(&lastUsedStr, "SELECT MAX(last_used_at) FROM client_tokens WHERE client_id = ?", cl.ClientID)
|
||||
|
||||
var lastUsed *time.Time
|
||||
if lastUsedTime.Valid && !lastUsedTime.Time.IsZero() {
|
||||
t := lastUsedTime.Time
|
||||
lastUsed = &t
|
||||
if lastUsedStr != "" {
|
||||
if t, err := time.Parse("2006-01-02 15:04:05", lastUsedStr); err == nil {
|
||||
lastUsed = &t
|
||||
}
|
||||
}
|
||||
|
||||
uiClients[i] = UIClient{
|
||||
|
||||
Reference in New Issue
Block a user