fix(log): the QSO number column was always empty

OrderedIDs scanned qso_date straight into a time.Time. The column holds a
formatted STRING — the repo writes it with Format(isoMillis) and reads it back
through parseTimeLoose everywhere else — so the scan failed on every call, the
index was never built, and omitempty then dropped the zero from the JSON. A
column that shipped blank.

Scans the string and parses only the newest row; the ordering already came from
SQL, so 30 000 parses were never needed.

Tested against a real SQLite file with the date stored exactly as the repo
writes it, and with the ids running opposite to the dates — the imported-ADIF
case that is the whole reason this is not the id. It fails without the fix with
the scan error itself.
This commit is contained in:
2026-08-13 00:37:53 +02:00
parent 62256942a1
commit 2484cd2515
2 changed files with 75 additions and 4 deletions
+11 -4
View File
@@ -3195,15 +3195,22 @@ func (r *Repo) OrderedIDs(ctx context.Context) ([]int64, time.Time, error) {
}
defer rows.Close()
out := make([]int64, 0, 4096)
var newest time.Time
// qso_date is stored as a formatted STRING, not a driver date. Scanning it
// into a time.Time silently fails on SQLite, which is how this returned an
// error and left the whole column empty.
var lastDate string
for rows.Next() {
var id int64
var at time.Time
var at string
if err := rows.Scan(&id, &at); err != nil {
return nil, time.Time{}, err
}
out = append(out, id)
newest = at // ascending, so the last row read is the newest
lastDate = at // ascending, so the last row read is the newest
}
return out, newest, rows.Err()
if err := rows.Err(); err != nil {
return nil, time.Time{}, err
}
// Parsed once, for the newest row only — the ordering came from SQL.
return out, parseTimeLoose(lastDate), nil
}