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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user