Skip to content

Itemized columns in function not working  #2386

Closed

Description

@jwc-clinnection

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

Activity

  1. added
    bugSomething isn't working
    triageNew issues that hasn't been reviewed
    on Jun 28, 2023
  2. saquibmian commented on Oct 3, 2023

    @saquibmian

    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.

  3. kyleconroy commented on Oct 24, 2023

    @kyleconroy
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions