Skip to content

Functions not working #2371

@jwc-clinnection

Description

@jwc-clinnection

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

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