Skip to content

sqlc.embed(<right_join_table>) should generate NULLable fields in LEFT/RIGHT JOIN #3240

@lordvidex

Description

@lordvidex

Version

1.25.0

What happened?

I have some table A and I made a LEFT JOIN on table B, but i used the sqlc.embed(b) on the table that I joined and unfortunately, I got non-nullable types.
The table that is OUTER JOINED should be always nullable but it seems the sqlc.embed somehow doesn't support this yet.

I worked around this by removing sqlc.embed for now, but the embed feature is really useful for my usecase.

Relevant log output

No response

Database schema

CREATE TABLE IF NOT EXISTS workflow(
   id BIGSERIAL PRIMARY KEY,
   org_id BIGINT NOT NULL,
   name TEXT NOT NULL,
   description TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS step (
    id BIGSERIAL PRIMARY KEY,
    workflow_id BIGINT NOT NULL REFERENCES workflow(id) ON DELETE CASCADE,
    index INT NOT NULL,
    title TEXT NOT NULL,
    description TEXT NOT NULL
);

SQL queries

SELECT wf.*, sqlc.embed(s) FROM (
    SELECT * from workflow w WHERE w.id = $1 LIMIT 1) wf 
LEFT JOIN step s ON s.workflow_id = wf.id

Configuration

No response

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions