Skip to content

[Bug?] Views with non-nullable properties are nullable in generated types #577

@xxRockOnxx

Description

@xxRockOnxx

Bug report

So as mentioned in the title: Views with non-nullable properties are nullable in generated types.

Describe the bug

Related StackOverflow question: https://stackoverflow.com/questions/17301323/why-are-my-views-columns-nullable

It seems like according to one of the answers:

The nullability tracking in PostgreSQL is not developed very much at all. In most places, it will default to claiming everything is potentially nullable, which is in many cases allowed by the relevant standards. This is the case here as well: Nullability is not tracked through views. I wouldn't rely on it for an application.

According to another one of the answers, you can also set the nullability manually.

The CLI seems to solely use Postgres as the source of truth.

That said, I'm not sure however if letting CLI check the base table would be an option.

It seems like either that or setting the attribute manually are the only options.

To Reproduce

  • Create a table
  • Create a view of that table
  • Generate type using supabase CLI

Expected behavior

Generated view properties are the same as the base table

System information

  • OS: Linux
  • Version of supabase-js: 2.0.4
  • Version of Node.js: 16.15.1

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