Skip to content

Conversation

Shadowfiend
Copy link

When generating TypeScript types, the current code "correctly" reports numeric types as number, as Postgres and Postgrest return such columns as JSON numbers by default without a query ::text cast.

However, generated insert and update types are limited to number, whereas the underlying APIs will accept a string and allow preserving precision that would be lost in conversion to JS number this way.

Generated types for inserting and updating numeric fields now include | string as a possibility to allow for this.

Closes #972.

When generating TypeScript types, the current code "correctly" reports
numeric types as `number`, as Postgres and Postgrest return such columns
as JSON numbers by default without a query `::text` cast.

However, generated insert and update types are limited to `number`,
whereas the underlying APIs will accept a string and allow preserving
precision that would be lost in conversion to JS `number` this way.

Generated types for inserting and updating numeric fields now include
`| string` as a possibility to allow for this.
@Shadowfiend Shadowfiend requested review from a team as code owners August 8, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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