fix: use sql.NullString for apiClientIP in logs query

Change apiClientIP from string to sql.NullString to properly handle
NULL values from the database, preventing potential runtime errors
when the column contains NULL entries.
This commit is contained in:
db123-test
2026-05-07 17:46:23 +03:30
parent 6ea4019d55
commit 3ba6d61117

View File

@@ -302,8 +302,8 @@ func logsHandler(db *sql.DB) http.HandlerFunc {
logs := make([]map[string]interface{}, 0)
for rows.Next() {
var ts time.Time
var action, apiClientIP string
var ip, reason sql.NullString
var action string
var ip, reason, apiClientIP sql.NullString
var ttlSeconds sql.NullInt64
if err := rows.Scan(&ts, &action, &ip, &ttlSeconds, &reason, &apiClientIP); err != nil {
continue