sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
12.27k stars 778 forks source link

Cannot embed empty row into struct #3123

Open erendogan51 opened 8 months ago

erendogan51 commented 8 months ago

Version

1.25.0

What happened?

When left joining two (or more) tables, where the selected values are embedded into structs using sqlc.embed, an error occurs when the joined table row is empty. The error states cannot scan NULL into *decimal.Decimal or in other cases *string. I think that this occurs because the columns are marked as NOT NULL in the schema, leading to sqlc thinking it can never be null. I would prefer that the struct be nil/zero valued.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

https://play.sqlc.dev/p/39c1fb54f9c5b0816d0fd0aee51053bfbe0541b8882a71e2ae42e03d02b9978b

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

anthonybishopric commented 8 months ago

2997 is related or the same