Fix ToggleReaction error handling - use pgx.ErrNoRows instead of sql.ErrNoRows

pgx returns pgx.ErrNoRows not sql.ErrNoRows for no rows result set, causing toggle reaction to fail
This commit is contained in:
Patrick Britton 2026-02-01 12:54:08 -06:00
parent 8c3ca59872
commit a3c609c0cc

View file

@ -2,10 +2,10 @@ package repository
import (
"context"
"database/sql"
"fmt"
"time"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/patbritton/sojorn-backend/internal/models"
"github.com/rs/zerolog/log"
@ -1094,7 +1094,7 @@ func (r *PostRepository) ToggleReaction(ctx context.Context, postID string, user
// Still need to calculate and return counts
goto calculate_counts
}
} else if err != sql.ErrNoRows {
} else if err != pgx.ErrNoRows {
log.Error().Err(err).Str("postID", postID).Str("userID", userID).Msg("DEBUG: Failed to check existing reaction - unexpected error")
return nil, nil, fmt.Errorf("failed to check existing reaction: %w", err)
} else {