Skip to content

Functions not working #2371

New issue

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

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

Already on GitHub? # to your account

Closed
jwc-clinnection opened this issue Jun 27, 2023 · 1 comment
Closed

Functions not working #2371

jwc-clinnection opened this issue Jun 27, 2023 · 1 comment

Comments

@jwc-clinnection
Copy link
Contributor

Version

1.18.0

What happened?

Functions do not generate correctly.

Relevant log output

// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.18.0
// source: query.sql

package db

import (
	"context"
)

const testFuncSelectBlog = `-- name: TestFuncSelectBlog :many
select  from test_select_blog($1)
`

type TestFuncSelectBlogRow struct {
}

func (q *Queries) TestFuncSelectBlog(ctx context.Context, pID int32) ([]TestFuncSelectBlogRow, error) {
	rows, err := q.db.QueryContext(ctx, testFuncSelectBlog, pID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []TestFuncSelectBlogRow
	for rows.Next() {
		var i TestFuncSelectBlogRow
		if err := rows.Scan(); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

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

No response

Playground URL

https://play.sqlc.dev/p/c881b75d6d80382f68d67618fb873d657b76e028db4f2d4c68a35d133bd6cd10

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 27, 2023
@kyleconroy kyleconroy added 📚 postgresql 🔧 golang 💻 linux and removed triage New issues that hasn't been reviewed labels Jul 6, 2023
@kyleconroy
Copy link
Collaborator

This is now partial fixed in v1.23.0. The star expansion will expand to a single return value, which will work once #2760 lands. I've opened a new issue to track better star expansion support for functions #2916

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

No branches or pull requests

2 participants