From a3c609c0cc7fec56ce4629e912f10a1b6802f534 Mon Sep 17 00:00:00 2001 From: Patrick Britton Date: Sun, 1 Feb 2026 12:54:08 -0600 Subject: [PATCH] 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 --- go-backend/internal/repository/post_repository.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go-backend/internal/repository/post_repository.go b/go-backend/internal/repository/post_repository.go index 6b760c8..4aff3ab 100644 --- a/go-backend/internal/repository/post_repository.go +++ b/go-backend/internal/repository/post_repository.go @@ -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 {