-
Notifications
You must be signed in to change notification settings - Fork 901
Open
Labels
bugSomething isn't workingSomething isn't workingtriageNew issues that hasn't been reviewedNew issues that hasn't been reviewed
Description
Version
1.23.0
What happened?
When using sqlc.embed
on something in combination with a LEFT JOIN
, meaning that the embedded table may be null, sqlc fails to parse the result when null. This happened with SQLite, but considering the nature of the issue, this might be relevant for other databases.
Relevant log output
sql: Scan error on column index 1, name "id": converting NULL to int64 is unsupported
Database schema
CREATE TABLE accounts(
id integer NOT NULL PRIMARY KEY AUTOINCREMENT
);
CREATE TABLE orders(
id integer NOT NULL PRIMARY KEY AUTOINCREMENT
);
CREATE TABLE account_orders(
account_id integer NOT NULL REFERENCES accounts(id),
order_id integer NOT NULL REFERENCES orders(id)
);
INSERT INTO accounts (id) VALUES (1);
SQL queries
-- name: GetAllAccounts :many
SELECT accounts.id, sqlc.embed(orders)
from accounts
LEFT JOIN account_orders ON accounts.id = account_orders.account_id
LEFT JOIN orders ON orders.id = account_orders.order_id;
Configuration
# Although irrelevant for this issue I believe
version: "2"
sql:
- engine: "sqlite"
queries: "infrastructure/sqlite/sqlc/queries"
schema: "infrastructure/sqlite/sqlc/schema.sql"
gen:
go:
package: "dao"
out: "infrastructure/sqlite/sqlc/dao"
emit_interface: true
Playground URL
No response
What operating system are you using?
Linux
What database engines are you using?
SQLite
What type of code are you generating?
Go
svenwltr, egtann, cyclimse, ayaanqui, mtibben and 22 moreguilhermealvess, cyclimse, theadell, advait and oliverselinger
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtriageNew issues that hasn't been reviewedNew issues that hasn't been reviewed