We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.20.0
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.
i.B
sql: Scan error on column index 2, name "id": converting NULL to int32 is unsupported
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 );
SELECT sqlc.embed(A), sqlc.embed(B) FROM A LEFT JOIN B ON A.id = B.a_id LIMIT 1;
No response
https://play.sqlc.dev/p/c045f5e33caf61f3e913a742f08518a167c247c4e5902a995f17ee200a553b2a](https://play.sqlc.dev/p/a6840c57f06a38387e9af1604059bb1db09e0db71f7a462c7bcd6a8dcfc42043
Linux
PostgreSQL
Go
The text was updated successfully, but these errors were encountered:
Ideally I would like something like this:
type NullableB { B B Valid bool } type GetARow struct { A A B NullableB }
But it might be tricky to Scan.
An alternative is to have NullableB be a copy of B with all its fields nullable… not ideal but maybe easier.
NullableB
B
Sorry, something went wrong.
this is a duplicate of #2348 and #2472
No branches or pull requests
Version
1.20.0
What happened?
The generated code
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
SQL queries
Configuration
No response
Playground URL
https://play.sqlc.dev/p/c045f5e33caf61f3e913a742f08518a167c247c4e5902a995f17ee200a553b2a](https://play.sqlc.dev/p/a6840c57f06a38387e9af1604059bb1db09e0db71f7a462c7bcd6a8dcfc42043
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: