Given this sqlc.yaml
file:
version: "2"
sql:
- engine: "postgresql"
schema: "internal/db/schema.sql"
queries: "internal/db/queries.sql"
gen:
go:
package: "db"
out: "internal/db"
sql_package: "pgx/v5"
this internal/db/schema.sql
:
CREATE SCHEMA go_htmx_todo;
CREATE TABLE go_htmx_todo.todos (
id integer NOT NULL,
task character varying(255) NOT NULL,
done boolean DEFAULT false NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
created_by integer NOT NULL,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_by integer NOT NULL
);
and this internal/db/queries.sql
:
-- name: GetTodo :one
SELECT * FROM go_htmx_todo.todos
WHERE id = $1 LIMIT 1;
when I run sqlc generate
with sqlc version v1.26.0, the following internal/db/models.go
file is generated:
package db
import (
"github.com/jackc/pgx/v5/pgtype"
)
type GoHtmxTodoTodo struct {
ID int32
Task string
Done bool
CreatedAt pgtype.Timestamp
CreatedBy int32
UpdatedAt pgtype.Timestamp
UpdatedBy int32
}
The question is how can I configure sqlc to generate the model’s struct name as Todo
instead of GoHtmxTodoTodo
i.e. to omit the schema name?