Closed as not planned
Description
Version
1.20.0
What happened?
The generated code
func (q *Queries) GetA(ctx context.Context) (GetARow, error) {
row := q.db.QueryRowContext(ctx, getA)
var i GetARow
err := row.Scan(
&i.A.ID,
&i.A.Name,
&i.B.ID,
&i.B.AID,
&i.B.Label,
)
return i, err
}
will fail when there is no B to join to A, because it did not detect that the whole i.B
is nullable.
Relevant log output
sql: Scan error on column index 2, name "id": converting NULL to int32 is unsupported
Database schema
CREATE TABLE A (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL
);
CREATE TABLE B (
id BIGSERIAL PRIMARY KEY,
a_id BIGINT NOT NULL,
label text NOT NULL
);
SQL queries
SELECT sqlc.embed(A), sqlc.embed(B) FROM A LEFT JOIN B ON A.id = B.a_id LIMIT 1;
Configuration
No response
Playground URL
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go