Skip to content

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

@jdgamble555

Description

@jdgamble555

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions