Skip to content

bug: Wrong error variable logged in SQL Select error handling #3189

@NitinKumar004

Description

@NitinKumar004

Description

In pkg/gofr/datasource/sql/db.go, the selectSlice() and selectStruct() methods check for row iteration errors using rows.Err(), but then log the wrong variable. They log the earlier query error (err) instead of the actual row iteration error (rows.Err()), making it impossible to diagnose row parsing failures from logs.

Steps to Reproduce

  1. Have a scenario where row iteration encounters an error (e.g., connection drop mid-read)
  2. Check the error log output

Expected Behavior

The log should show the actual row iteration error returned by rows.Err().

Actual Behavior

The log shows the earlier query error variable which is nil at that point, so the log message contains no useful error information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions