fix: cast week_start to text in SELECT and add error logging for silent 500
pgx v5 cannot scan a PostgreSQL DATE column directly into a Go string. The WHERE clause already used week_start::text but the SELECT did not, causing GetByWeek to return a scan error that the GenerateMenu handler swallowed without logging (just returned 500). - repository.go: SELECT mp.week_start::text instead of mp.week_start - handler.go: add slog.Error before the silent 500 branch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,7 @@ func NewRepository(pool *pgxpool.Pool) *Repository {
|
||||
// Returns nil, nil when no plan exists for that week.
|
||||
func (r *Repository) GetByWeek(ctx context.Context, userID, weekStart string) (*MenuPlan, error) {
|
||||
const q = `
|
||||
SELECT mp.id, mp.week_start,
|
||||
SELECT mp.id, mp.week_start::text,
|
||||
mi.id, mi.day_of_week, mi.meal_type,
|
||||
sr.id, sr.title, COALESCE(sr.image_url, ''), sr.nutrition
|
||||
FROM menu_plans mp
|
||||
|
||||
Reference in New Issue
Block a user