Closed
Description
Version
1.22.0
What happened?
When omit_unused_structs
is set to true
, enums inside an sqlc.embed is ignored. This can cause invalid golang code due to undefined type on the model.
Can be circumvented by creating another query without embed just so the enum model exists in the generated code.
Relevant log output
check generated models.go
Database schema
CREATE TYPE enumtype AS ENUM('a','b');
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
e enumtype not null
);
SQL queries
-- name: GetAllAuthors :one
SELECT sqlc.embed(authors) FROM authors;
Configuration
{
"version": "1",
"packages": [
{
"path": "db",
"engine": "postgresql",
"schema": "query.sql",
"queries": "query.sql",
"omit_unused_structs": true
}
]
}
Playground URL
https://play.sqlc.dev/p/2203df48ffefbead62b4871ccb2269b8cdd425c64c27108b7857d79c89a5596d
What operating system are you using?
Linux, Windows
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go