cannot scan NULL into *string
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 14.3k
- Forks
- 1.1k
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 11
Description
I have table with nullable values (email and avatar_url in my case)
`CREATE TABLE IF NOT EXISTS users
(
id int NOT NULL PRIMARY KEY,
email varchar(127),
avatar_url varchar(255),
created_at timestamp default now(),
updated_at timestamp default now()
);
`
I am trying to scan `SELECT * from users` into object like
`
type PostSearchResult struct {
Id int json:"id"
CreatedAt pgtype.Timestamp json:"created_at"
UpdatedAt pgtype.Timestamp json:"updated_at"
AvatarUrl string json:"avatar_url"
Email string json:"email"
}
`
When email or avatarUrl is null, then i got error
`cannot scan NULL into *string`
Can I avoid this somehow? Or this is known bug?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files, tests, or entry points. Start by reproducing the provided users table and SELECT query with nullable email and avatar_url values, then inspect how pgx scans NULL into the shown Go struct. Done would require a confirmed handling approach or a narrowly defined project change, neither of which is specified here.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100