Open
Description
Version
1.28.0
What happened?
When creating an insert query using a CTE results in an error. The relation with the CTE does not exist, according to sqlc:
relation "potential_authors" does not exist
I've recreated a simplified version of the issue in the playground.
Relevant log output
Database schema
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL,
bio text
);
CREATE TABLE dummy (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL,
bio text
);
SQL queries
-- name: CreateAuthor :exec
INSERT INTO authors
WITH potential_authors AS (
SELECT id, name, bio
FROM dummy
)
SELECT id, name, bio
FROM potential_authors;
Configuration
version: "2"
cloud:
organization: ""
project: ""
hostname: ""
sql:
- schema: ./sql/schema.sql
queries: ./sql/queries
engine: mysql
gen:
go:
package: sqlc
out: ./_sqlc
emit_json_tags: true
emit_prepared_queries: false
emit_interface: false
emit_exact_table_names: true
overrides:
go: null
plugins: []
rules: []
options: {}
Playground URL
https://play.sqlc.dev/p/39948b645032d9910dee27400711e18e91a35b803282bc256bee82afa681bff8
What operating system are you using?
Linux
What database engines are you using?
MySQL
What type of code are you generating?
Go