Skip to content

Types do NOT work for Computed Relationship, even with overrideTypes #620

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
1 of 2 tasks
jdgamble555 opened this issue May 25, 2025 · 1 comment
Open
1 of 2 tasks
Labels
bug Something isn't working

Comments

@jdgamble555
Copy link

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Here is the actual type of all roles, and me trying to use it. You can see it is correctly an array and has no null value in it.
Type

However, I get this error, which says I can't set a single value to an array. Clearly, other parts of Supabase knows this IS an array.

Types Error

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a computed function that returns a SETOF of any table.
  2. Try to use it inside the original

An easy test would be to create a computed function on the profiles table that returns a SETOF any other table records (see below).

Expected behavior

I shouldn't need to use override at all, but the return value is single and possibly null outside the box. Here is what it looks like.

Original Types

Function

Here is my actual computed function, but it could be any table.

CREATE OR REPLACE FUNCTION public.all_roles(profiles)
RETURNS SETOF public.roles
LANGUAGE sql
SET search_path = ''
AS $$
  SELECT * FROM public.roles;
$$;

The purpose of this, of course, is to be able to query the database once and remove extraneous fetches.

System information

"@supabase/ssr": "^0.6.1",
"@supabase/supabase-js": "^2.49.8"

Additional context

I think BOTH override needs to be fixed and the original type problem.

J

@jdgamble555 jdgamble555 added the bug Something isn't working label May 25, 2025
@jdgamble555
Copy link
Author

jdgamble555 commented May 26, 2025

So I fixed the overrideTypes problem like a dummy.

.overrideTypes<{
    all_roles: Database['public']['Functions']['all_roles']['Returns']
}[]>();

and of course forgot the:

all_roles(role_name, role_id)

Original problem still needs to be fixed, as I shouldn't have to overrrideTypes().

Any time line on this? Creating manual types for complex relationships gets tedius.

J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant