Open
Description
Version
1.23.0
What happened?
For functions that return records, sqlc will expand to a single column with the same name as the function. This works for PostgreSQL, but results in an interface
type due to #2760. Instead, by default, star expansion should create a column for each field on the record.
// CURRENT
const testFuncSelectBlog = `-- name: TestFuncSelectBlog :many
select test_select_blog from test_select_blog($1)
`
// WANTED
const testFuncSelectBlog = `-- name: TestFuncSelectBlog :many
select id, name from test_select_blog($1)
`
Relevant log output
No response
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 * from test_select_blog($1);
Configuration
version: "2"
cloud:
project: "<PROJECT_ID>"
sql:
- schema: "schema.sql"
queries: "query.sql"
engine: "postgresql"
database:
managed: true
gen:
go:
out: db
sql_package: "pgx/v5"
Playground URL
https://play.sqlc.dev/p/0e0719e69ade689d47546ee075d7f0ae2c9c0fb67f4fd31484841bd70d070197
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
No response