sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Cannot embed empty row into struct

Open erendogan51 opened this issue 1 year ago • 1 comments

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

erendogan51 avatar Jan 10 '24 10:01 erendogan51

#2997 is related or the same

anthonybishopric avatar Jan 11 '24 16:01 anthonybishopric