hasura / hasura/graphql-engine

Is it possible to return SETOF <type-name> in a custom function?

Open
#3,865 2 comments 3 reactions 0 assignees View on GitHub
k/ideas
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

When creating a function, it must return all the rows of a table:

> Return type: MUST be `SETOF `

Why can I not return `SETOF `, for example:

```sql
CREATE TYPE my_type AS (f1 text, f2 text);
```

There is a workaround where you can create a table with the required rows and return a `SETOF` that, but would types be neater?

Contributor guide

Open the contributing guide

Research direction

The issue provides no repository file or test entry point. Start by tracing how custom PostgreSQL functions and declared return types are handled, then determine whether SETOF a user-defined composite type is supported; done would require an agreed behavior and corresponding implementation or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgres
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.