You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
createtableblog (
id serialprimary key,
name textnot null
);
createfunctiontest_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 :manyselect id, name from test_select_blog($1);
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.
Activity
saquibmian commentedon Oct 3, 2023
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.test: Add case for #2386
test: Add more test cases for new analyzer (#2879)
kyleconroy commentedon Oct 24, 2023
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
test: Add more test cases for new analyzer (sqlc-dev#2879)