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
We've had an issue where a query we did a LEFT JOIN in didn't generate Null* fields in the *Row struct, resulting in the converting NULL to %s is unsupported error at runtime.
We found out this was fixed by putting an INNER JOIN that came after that LEFT JOIN before it. Somehow, query TestLeftInner generates a different struct than query TestInnerLeft:
type TestLeftInnerRow struct {
A string
B string
C string
}
type TestInnerLeftRow struct {
A string
B string
C sql.NullString
}
Relevant log output
No response
Database schema
CREATETABLEa (
id BIGSERIALPRIMARY KEY,
a TEXTNOT NULL
);
CREATETABLEb (
id BIGSERIALPRIMARY KEY,
b TEXTNOT NULL,
a_id BIGINTNOT NULLREFERENCES a (id)
);
CREATETABLEc (
id BIGSERIALPRIMARY KEY,
c TEXTNOT NULL,
a_id BIGINTNOT NULLREFERENCES a (id)
);
SQL queries
-- name: TestLeftInner :manySELECTa.a, b.b, c.cFROM b
LEFT JOIN c ONc.a_id=a.idINNER JOIN a ONb.a_id=a.id;
-- name: TestInnerLeft :manySELECTa.a, b.b, c.cFROM b
INNER JOIN a ONb.a_id=a.idLEFT JOIN c ONc.a_id=a.id;
Version
1.15.0
What happened?
We've had an issue where a query we did a LEFT JOIN in didn't generate
Null*
fields in the*Row
struct, resulting in theconverting NULL to %s is unsupported
error at runtime.We found out this was fixed by putting an INNER JOIN that came after that LEFT JOIN before it. Somehow, query
TestLeftInner
generates a different struct than queryTestInnerLeft
:Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/56e981109a258f404058dd3cfe845c8fd0e0b195c0f3410479a819caea2c72ef
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL, MySQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: