Skip to content

For numeric columns, TypeScript type generation does not include string as an option for inserts and updates #972

@Shadowfiend

Description

@Shadowfiend

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 generating TypeScript types, the current code “correctly” converts numeric types to number, as Postgres and Postgrest return such columns as JSON numbers by default without a query cast to ::text.

However, generated insert and update types are limited to number, whereas the underlying APIs will accept a string and preserve precision this way. As such, the generated update and insert types for these fields should allow for string parameters.

To Reproduce

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

  1. Define a table with column type NUMERIC or DECIMAL.
  2. Generate TypeScript types for the table.
  3. Observe that the Row type is number, but so are the Insert and Update types.

Expected behavior

number | string is used instead for Insert and Update types.

Additional context

Currently we're having to cast strings as unknown as number or @ts-expect-error for all insert/update calls to get around this.

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