Closed
Description
Version
1.23.0
What happened?
The attached playground generates code that can't be compiled because of the missing pgtype
import. This is because the ResetTaskRunRow
struct is not used in ResetTaskRun
, because the query is specified as exec
.
Either sqlc should not generate the struct it is not using OR complain about the mismatch between the :exec
annotation and the fact that the statement returns data. I would prefer the latter as this is now the second time I've ran into the issue of confusion because I changed the SQL of a statement without fixing the annotation, and each time it's been a royal pain to find.
Relevant log output
No response
Database schema
CREATE TABLE IF NOT EXISTS job
(
task_name text NOT NULL,
last_run timestamp with time zone DEFAULT now() NOT NULL
);
SQL queries
-- name: ResetTaskRun :exec
UPDATE job
SET last_run = NOW()
FROM (
SELECT last_run,
task_name
FROM job AS o
WHERE o.task_name = $1
FOR UPDATE
) AS old_values
WHERE job.task_name = $1
RETURNING job.last_run AS this_run,
old_values.last_run AS last_run;
Configuration
{
"version": "2",
"sql": [
{
"schema": "schema.sql",
"queries": "query.sql",
"engine": "postgresql",
"gen": {
"go": {
"out": "db",
"sql_package": "pgx/v5",
}
}
}
]
}
Playground URL
https://play.sqlc.dev/p/3968fbdbe70621e70093ca0efca43a1e3bbb4ad5835d60b57d0167f5397bb0d6
What operating system are you using?
No response
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go