fix: update type handling for schema changes
- Fix pgtype.UUID usage in test files by properly converting string UUIDs to pgtype.UUID - Update numericToFloat to use pgtype.Float8 instead of pgtype.Numeric for DOUBLE PRECISION support - Fix field name from WebURL to WebUrl to match current schema These changes align with the recent community_rating type change to DOUBLE PRECISION and ensure consistent type handling across the codebase.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"mime"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -444,7 +445,11 @@ func (h *MediaHandler) HandleBulkDelete(c *echo.Context) error {
|
||||
}
|
||||
|
||||
if media.FilePath != "" {
|
||||
os.Remove(media.FilePath)
|
||||
if err := os.Remove(media.FilePath); err != nil {
|
||||
// Log file removal failure but don't fail the request
|
||||
// DB record is already deleted, which is the primary concern
|
||||
log.Printf("Warning: failed to remove file %s: %v", media.FilePath, err)
|
||||
}
|
||||
}
|
||||
|
||||
results = append(results, map[string]interface{}{
|
||||
@@ -1644,12 +1649,9 @@ func (mh *MediaHandler) ServeFile(c *echo.Context) error {
|
||||
}
|
||||
|
||||
// numericToFloat converts pgtype.Numeric to float64, returning 0 if invalid
|
||||
func numericToFloat(n pgtype.Numeric) float64 {
|
||||
func numericToFloat(n pgtype.Float8) float64 {
|
||||
if n.Valid {
|
||||
f, err := n.Float64Value()
|
||||
if err == nil {
|
||||
return f.Float64
|
||||
}
|
||||
return n.Float64
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user