supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
965 stars 129 forks source link

Add support for type casting (id::text) #429

Closed ozanmakes closed 4 months ago

ozanmakes commented 1 year ago

What kind of change does this PR introduce?

This change adds support for type casting in select queries. For example an id column with the type bigint can be casted to text by "id::text".

Equivalent PostgreSQL type for TypeScript type is based on the type generator pgTypeToTsType function.

What is the current behavior?

Fixes https://github.com/supabase/postgrest-js/issues/370

What is the new behavior?

Additional context

This is by no means a complete list of all possible type casts nor is it sound, but this is much less error prone than having to do an unsafe cast such as

supabase.from("users").select("id::text").returns<{ id: string }[]>
ozanmakes commented 7 months ago

Hi @soedirgo. Any chance this can be reviewed?

github-actions[bot] commented 4 months ago

:tada: This PR is included in version 1.11.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: