postgrest-js icon indicating copy to clipboard operation
postgrest-js copied to clipboard

feat(types): add inference for embeded joins by functions

Open avallete opened this issue 8 months ago • 0 comments

What kind of change does this PR introduce?

Once https://github.com/supabase/postgres-meta/pull/915 is merged

This introduce automatic types inferences for "joins based on functions" to postgrest-js.

Along with the type generation in pg-meta it should allows queries such as:

postgrest
        .from('organizations')
        .select('subscription_id, custom_function_returning_setof_other_table(customer_id)')

To work out of the box.

It also introduce a way to "force cast" an object relation as being not nullable at the database override level in case some DB layer app logic enforce it.

This should not be a breaking change since everything has be scoped in an additional type.

Fixes: CLIBS-79

Related: https://github.com/supabase/supabase-js/issues/1259

Edit: Tested the full pipeline (typegen + inference) over our infra repo, was able to get rid of all types override for the billing_subscriptions (see: https://github.com/supabase/infrastructure/compare/develop...chore/upgrade-supabase-js)

avallete avatar Mar 30 '25 15:03 avallete