Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type not propagated from CTE query #3875

Open
binaek opened this issue Mar 7, 2025 · 0 comments
Open

Type not propagated from CTE query #3875

binaek opened this issue Mar 7, 2025 · 0 comments
Labels
📚 postgresql bug Something isn't working

Comments

@binaek
Copy link

binaek commented Mar 7, 2025

Version

1.28.0

What happened?

Reproduction:

CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);
-- name: GetAuthor :one
WITH author as (
  SELECT * FROM authors
  WHERE id = $1
)
SELECT * from author;

The return type of the generated function is SelectCteTestRow - not Author although it's actually returning a Author.

Relevant log output

Database schema

SQL queries

Configuration

Playground URL

https://play.sqlc.dev/p/0d129e7ba6230256015139134fbdadb991601360635c1983117970d299b3df9e

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@binaek binaek added the bug Something isn't working label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 postgresql bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant