v0.61.1 introduces bug in typescript generation for computed column
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- postgresql, typescript
- Domain
- databases
Research direction
Start at src/lib/sql/functions.sql line 44 and reproduce the issue with the provided gen types typescript command using the sample people table and full_name function. Confirm that the generated full_name field is typed as string | null rather than unknown | null, then verify the generated output matches the expected TypeScript shape.
Written by the indexing model from the issue text.
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
The below line introduced the bug in v0.61.1
https://github.com/supabase/postgres-meta/blob/e4dc2177cded3e06d07301570b2395099d860d24/src/lib/sql/functions.sql#L44
- rt.typname as return_type,
+ pg_get_function_result(f.oid) as return_type,
The above results in computed column typehint always equal to unknown
To Reproduce
Setup Supabase with the following schema:
CREATE TABLE people (
fname text,
lname text
);
CREATE FUNCTION full_name(people) RETURNS text AS $$
SELECT $1.fname || ' ' || $1.lname;
$$ LANGUAGE SQL;
Run
node \
--no-warnings \
dist/server/server.js \
gen types typescript \
--include-schemas public
Or the following if docker-compose is setup with meta using v0.61.1:
docker-compose exec -T meta node \
--no-warnings \
dist/server/server.js \
gen types typescript \
--include-schemas public
Expected behavior
The typescript generated should be
export interface Database {
public: {
Tables: {
account: {
Row: {
fname: string | null;
lname: string | null;
full_name: string | null;
};
}
}
...
Screenshots
The typescript generated is however
export interface Database {
public: {
Tables: {
account: {
Row: {
fname: string | null;
lname: string | null;
full_name: unknown | null;
};
}
}
...
System information
- OS: macOS
- Browser (if applies): N/A
- Version of supabase-js: N/A
- Version of Node.js: N/A
Additional context
Reverting the changes of the below resolve the issue
https://github.com/supabase/postgres-meta/blob/e4dc2177cded3e06d07301570b2395099d860d24/src/lib/sql/functions.sql#L44
- rt.typname as return_type,
+ pg_get_function_result(f.oid) as return_type,
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 223
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from supabase/postgres-meta
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
supabase/postgres-meta#1150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
supabase/postgres-meta#1147 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
supabase/postgres-meta#1146 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
supabase/postgres-meta#1143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
supabase/postgres-meta#1142 ·
All issues in supabase/postgres-meta
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·