Closed
Description
Version
1.11.0
What happened?
When a function returns a TABLE
type, you get an "empty list" error or something like that. I'm sorry I saw this earlier today and don't have the exact output, but the repro below should work.
sqlc generate
fails due to an error.
Relevant log output
No response
Database schema
CREATE TABLE accounts (
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMAR KEY,
username TEXT NOT NULL UNIQUE,
password TEXT NOT NULL
);
-- this is a useless and horrifying function cause we don't hash
-- the password, this is just to repro the bug in sqlc
CREATE OR REPLACE FUNCTION register_account(
_username TEXT,
_password VARCHAR(70)
)
RETURNS TABLE (
account_id INTEGER
)
AS $$
BEGIN
INSERT INTO accounts (username, password)
VALUES (
_username,
_password
)
RETURNING id INTO account_id;
RETURN NEXT;
END;
$$ LANGUAGE plpgsql;
SQL queries
-- name: Foo :one
SELECT * FROM register_account('a', 'b');
Configuration
No response
Playground URL
No response
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go