jackc / jackc/pgx

can't scan into dest[77]: type assertion to []byte failed

Open
#2,237 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
14.3k
Forks
1.1k
Avg merge
6d 9h
Merged PRs (30d)
11

Description

**Describe the bug**
can't scan into dest[77]: type assertion to []byte failed

**To Reproduce**

```go
func (s *matchParticipantsService) GetByGameIDsAndRegion(gameIDs []int64, rgn region.Region) ([]models.LeagueOfLegendsMatchParticipant, error) {
query := `SELECT * FROM lol_match_participants WHERE game_id = ANY($1::bigint[]) AND region = $2`

rows, err := s.pgxPool.Query(s.ctx, query, gameIDs, rgn)
if err != nil {
return nil, err
}
defer rows.Close()

return pgx.CollectRows(rows, pgx.RowToStructByName[models.LeagueOfLegendsMatchParticipant])
}
```

I cannot provide the LeagueOfLegendsMatchParticipant type.

**Expected behavior**
pgx should successfully scan results

**Actual behavior**
can't scan into dest[77]: type assertion to []byte failed

**Version**
- Go: `go version go1.23.3 windows/amd64`
- PostgreSQL: `17.2`
- pgx: `github.com/jackc/pgx/v5 v5.7.2`

The error does not occur when using `github.com/jackc/pgx/v5 v5.7.1`

Contributor guide

Open the contributing guide

Research direction

Start at GetByGameIDsAndRegion and the pgx.CollectRows/RowToStructByName call shown in the report; compare behavior between pgx v5.7.1 and v5.7.2 with the provided PostgreSQL query. The unavailable LeagueOfLegendsMatchParticipant type is needed to reproduce the failure, and done means explaining why v5.7.2 cannot scan one destination and verifying successful result scanning.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.