You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The supabase gen types appears to lack support for RPC functions returning objects with nullable properties.
Steps to reproduce:
Define an RPC function:
CREATETYPEstatus_type_enumAS ENUM ('rotten', 'ripe');
CREATEFUNCTIONget_bananas(
_limit INT DEFAULT NULL,
_offset INT DEFAULT 0
)
RETURNS TABLE (
id UUID,
textTEXT,
current_status status_type_enum -- Is there a way to make this nullable in TS?
)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECTb.id,
b.text,
s.status_typeAS current_status
FROM bananas b
LEFT JOIN statuses s ONb.id=s.banana_idANDs.user_id=auth.uid()
LIMIT _limit
OFFSET _offset;
END;
$$;
Run the command:
npx supabase gen types
Examine the generated types:
It doesn't seem possible to make current_status nullable out of the box, even though it can be missing.
use the PartialNullBy type for supabase to wrap the object part of what you get back. I've included the ArrayElement type so you can apply it to the object part of the type when you're getting a whole array (table) of objects. I also included a PartialBy just for completeness, which will do the same thing using undefined instead.
The
supabase gen types
appears to lack support for RPC functions returning objects with nullable properties.Steps to reproduce:
Define an RPC function:
Run the command:
Examine the generated types:
It doesn't seem possible to make
current_status
nullable out of the box, even though it can be missing.Workaround
Extend the generated types from another file to overwrite properties.
The text was updated successfully, but these errors were encountered: