sqlc
sqlc copied to clipboard
Error running sqlc generate
Version
1.14.0
What happened?
Cannot not generate queries
Relevant log output
error generating code: template: interfaceCode.tmpl:12:71: executing "interfaceCodePgx" at <.Ret.DefineType>: error calling DefineType: no type for QueryValue:
Database schema
create table categories
(
id serial primary key,
created_at timestamp with time zone default CURRENT_TIMESTAMP not null,
updated_at timestamp with time zone,
deleted_at timestamp with time zone,
name text not null,
image text default '' :: text,
user_id bigint not null
constraint fk_user references users on delete cascade
);
SQL queries
-- name: ListCategories :many
select *
from categories
where categories.user_id = $1;
Configuration
version: "1"
packages:
- name: "db"
path: "internal/postgresql/db"
queries: "internal/postgresql/sql/queries/"
sql_package: "pgx/v4"
schema: "internal/postgresql/migrations"
engine: "postgresql"
emit_json_tags: true
emit_db_tags: false
emit_prepared_queries: true
emit_interface: true
emit_exact_table_names: true
emit_empty_slices: true
emit_exported_queries: false
emit_result_struct_pointers: true
emit_methods_with_db_argument: false
Playground URL
No response
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
I cannot reproduce the error with the examples you gave. However, I can reproduce it with a slightly different query.
-- name: ListCategories :one
select
from categories
where categories.user_id = $1;
I changed ":many" to ":one" (otherwise the error is in a different line of the template) I omitted the star in the select statement. Now this looks very similar to #1676. If you agree, we can close this one as a duplicate.
Agreed with @akutschera about this being a duplicate
Duplicate of https://github.com/kyleconroy/sqlc/issues/1676