8000 fix: make virtual columns nullable (#480) · supabase/postgres-meta@f4a11e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit f4a11e4

Browse files
fix: make virtual columns nullable (#480)
psteinroe contributed a change which adds schema functions which take only the table name as columns on the tables when generating TypeScript types. This commit extends that to treat function return types as nullable. The function used in `oo-init.sql` could be changed like so: ```sql create function public.blurb(public.todos) returns text as $$ select null; $$ language sql stable; ``` It would still compile and be a valid function despite the unchanged return type, which means any function must be treated as potentially returning `null` in the types. I have also updated instructions for building and testing the TypeScript type generation.
1 parent 6b26b00 commit f4a11e4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ To start developing, run `npm run dev`. It will set up the database with Docker
100100

101101
If you are fixing a bug, you should create a new test case. To test your changes, add the `-u/--updateSnapshot` flag to `jest` on the `test:run` script, run `npm run test`, and then review the git diff of the snapshots. Depending on your change, you may see `id` fields being changed - this is expected and you are free to commit it, as long as it passes the CI. Don't forget to remove the `-u/--updateSnapshot` flag when committing.
102102

103+
To make changes to the TypeScript type generation, run `npm run gen:types:typescript` while you have `npm run dev` running.
104+
103105
## Licence
104106

105107
Apache 2.0

src/server/templates/typescript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export interface Database {
9090
fn.return_type,
9191
types,
9292
schemas
93-
)}`
93+
)} | null`
9494
),
9595
]}
9696
}

0 commit comments

Comments
 (0)
0