Skip to content

Itemized columns in function not working #2386

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

Closed
jwc-clinnection opened this issue Jun 28, 2023 · 2 comments
Closed

Itemized columns in function not working #2386

jwc-clinnection opened this issue Jun 28, 2023 · 2 comments

Comments

@jwc-clinnection
Copy link
Contributor

Version

1.18.0

What happened?

When not using * (A_Star) and itemizing columns, functions fail to generate.

Relevant log output

sqlc generate failed.

# package db
query.sql:15:8: column "id" does not exist

Database schema

create table blog (
    id serial primary key,
    name text not null

);

create function test_select_blog(in p_id int)
    returns table (id int, name text) AS $$
BEGIN RETURN QUERY
    select id, name from blog where id = p_id;
END;
$$ language plpgsql;

SQL queries

-- name: TestFuncSelectBlog :many
select id, name from test_select_blog($1);

Configuration

No response

Playground URL

https://play.sqlc.dev/p/122897d98d937d01051777c6ab253ccb16e5c20d513c03c4e1049bf36349f4f5

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@jwc-clinnection jwc-clinnection added bug Something isn't working triage New issues that hasn't been reviewed labels Jun 28, 2023
@kyleconroy kyleconroy added 📚 postgresql 🔧 golang 💻 linux and removed triage New issues that hasn't been reviewed labels Jul 6, 2023
@saquibmian
Copy link

Is there any workaround for this? The best I can think of is to create a fake table that matches the composite table declaration and use setof <table name> instead, but this is far from ideal.

kyleconroy added a commit that referenced this issue Oct 18, 2023
kyleconroy added a commit that referenced this issue Oct 18, 2023
* test: Add case for #2132
* test: Add case for #2152
* test: Mark case for #2152
* test: Add case for #2187
* test: Add case for #2226
* test: Add case for #2364
* test: Add case for #2386
* test: Add case for #2538
* test: Add case for #2644
* test: Add case for #2731
@kyleconroy
Copy link
Collaborator

This is fixed in v1.23.0 by enabling the database-backed query analyzer. We added a test case for this issue so it won’t break in the future.

You can play around with the working example on the playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants