You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A RIGHT or FULL JOIN doesn't make the joins to its left nullable #4690
A RIGHT JOIN or FULL JOIN makes everything joined before it nullable, and a parenthesised join on the nullable side of a LEFT JOIN is nullable as a whole. sqlc decides each join from its own type alone, so the tables of the earlier join are generated as never null.
For the query below I get Name string. I expected pgtype.Text: a book whose author_id matches no author comes back with a NULL name.
typeListTitlesRowstruct {
NamestringTitlestring
}
The same happens with FROM authors a LEFT JOIN (books b JOIN books c ON c.id = b.id) ON b.author_id = a.id: the columns of b and c are never null.
It is the same on main (3ad8b20). I found no existing issue; #604 is a different case.
isTableRequired passes a fixed value down for each join type and ignores the side it was reached through. A five-line fix with test cases is here: Bockit@fd812e9
The analysis was done with AI help and checked by me.
Relevant log output
No response
Database schema
CREATETABLEauthors (id BIGSERIALPRIMARY KEY, name textNOT NULL);
CREATETABLEbooks (id BIGSERIALPRIMARY KEY, author_id bigintNOT NULL, title textNOT NULL);
SQL queries
-- name: ListTitles :manySELECTa.name, c.titleFROM authors a
LEFT JOIN books b ONb.author_id=a.idRIGHT JOIN books c ONc.author_id=a.id;
Activity