Is Inner join possible for a relation from public table to a custom schema table in the js client? #6550
-
|
Let say I have a custom schema enums that contains a ctegory table: create table enums.category (
id smallint PRIMARY KEY UNIQUE,
parent smallint references enums.category,
name VARCHAR(100),
);also we have a post with a fk relation to enums.category: create table post (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
owner uuid references public.user not null,
title VARCHAR (300) NOT NULL,
category smallint references enums.category NOT NULL
);when I tried:: let { data, error } = await supabase.from("post").select("*, category (*)");
response
{"message":"Could not find a relationship between 'post' and 'category' in the schema cache","hint":"Verify that 'post' and 'category' exist in the schema 'public' and that there is a foreign key relationship between them. If a new relationship was created, try reloading the schema cache."}Is it possible to do the inner join and do select operation and filtering on relationships from a custom schema? |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 6 replies
-
|
It's not possible to do cross-schema joins directly for now - but you can create a view of Basically: CREATE VIEW public.category AS
SELECT * FROM enums.category
-- Extra step for making sure RLS applies to your view
ALTER VIEW public.category OWNER TO authenticated;Then your JS snippet should work. |
Beta Was this translation helpful? Give feedback.
-
|
@steve-chavez Any update on this feature? Would be extremely helpful |
Beta Was this translation helpful? Give feedback.
-
|
Having the same issue. My I would like to join const { data: accountsData, error: accountsError } = await supabase
.from('accounts')
.select('id, first_name, last_name, auth.users(email)')
.eq('company_id', company_id);But I get this error: {
code: 'PGRST100',
details: 'unexpected "u" expecting "sum", "avg", "count", "max" or "min"',
hint: null,
message: '"failed to parse select parameter (id,first_name,last_name,auth.users(email))" (line 1, column 30)'
}I tried {
code: 'PGRST200',
details: "Searched for a foreign key relationship between 'accounts' and 'users' in the schema 'public', but no matches were found.",
hint: null,
message: "Could not find a relationship between 'accounts' and 'users' in the schema cache"
} |
Beta Was this translation helpful? Give feedback.
-
|
Supabase lacks support on multi schema. event the studio (editor) resets the schema to public everytime it redirects. |
Beta Was this translation helpful? Give feedback.
-
|
any update here? |
Beta Was this translation helpful? Give feedback.
-
|
This is a very annoying problem and that strongly contributes to bad dx. I hope supabase fixes this soon or provide documentation on how to properly handle this. |
Beta Was this translation helpful? Give feedback.
-
|
still no fix in 2025 |
Beta Was this translation helpful? Give feedback.
-
|
Just happened to me, three years since the first question and no fix yet |
Beta Was this translation helpful? Give feedback.
-
|
you can do it in a function. |
Beta Was this translation helpful? Give feedback.

It's not possible to do cross-schema joins directly for now - but you can create a view of
enums.categoryinto thepublicschema to make it work.Basically:
Then your JS snippet should work.