Skip to content
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

Joining relationships from .rpc function calls throws error #1259

Open
2 tasks done
davidfant opened this issue Aug 18, 2024 · 0 comments
Open
2 tasks done

Joining relationships from .rpc function calls throws error #1259

davidfant opened this issue Aug 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@davidfant
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

I'm getting errors when joining relationships from rpc function calls, but the supabase-js SDK infers the correct types (suggesting it is possible)

To Reproduce

I have a Postgres function

CREATE OR REPLACE FUNCTION public."getTokenLineage"(...)
 RETURNS TABLE("triggerId" uuid, ...)
 LANGUAGE plpgsql
AS $function$
BEGIN
	...

This performs a complex filter and returns a list of triggerIds, which map to the triggers table. To fetch this I'm doing:

const triggers = await supabase.rpc("getTokenLineage", { ... });

When I write the following, supabase-js type inference correctly shows me the right types

const triggers = await supabase
    .rpc("getTokenLineage", { ... })
    .select(
      `
        triggerId,
        trigger(
          id,
          status
        )
    `
    )
image

However that query doesn't work and gives the following error:

{
   code: 'PGRST200',
   details: "Searched for a foreign key relationship between 'record' and 'trigger' in the schema 'public', but no matches were found.",
   hint: null,
   message: "Could not find a relationship between 'record' and 'trigger' in the schema cache",
   digest: '2363637366'
}

Expected behavior

The trigger table is joined and in the select statement I can join arbitrary fields and relationships

System information

  • OS: macOS
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-js: @supabase/supabase-js@^2.43.4
  • Version of Node.js: v21.1.0
@davidfant davidfant added the bug Something isn't working label Aug 18, 2024
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