Skip to content

Allow strings for numeric type inserts and updates #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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