postgrest-js icon indicating copy to clipboard operation
postgrest-js copied to clipboard

Generated type for `JSONB NOT NULL` column allows `null`

Open nicksiscoe opened this issue 1 year ago • 0 comments

Bug report

  • [x] I confirm this is a bug with Supabase, not with my own application.
  • [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When I create a JSONB column that is explicitly NOT NULL, I can see that null values are not allowed according to Supabase Studio (it understands the Postgres restriction exists).

image

When I generate Typescript types for this database, however, the Json type for this column allows null.

image image

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a non-nullable JSONB column
  2. Run supabase gen types --lang=typescript
  3. View the generated type for the column, which is Json

Expected behavior

I would expect the Typescript type for this column to be NonNullable<Json>.

Screenshots

(See above)

System information

  • OS: macOS
  • supabase: ^1.200.3
  • Node: v20

nicksiscoe avatar Nov 21 '24 18:11 nicksiscoe