Skip to content

Generated type for JSONB NOT NULL column allows null #585

@nicksiscoe

Description

@nicksiscoe

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions