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
I tried creating a client with my custom schema named tasks. But it throws errors and doesn't work.
Errors in the editor
Code for the request:
import{createClient}from"@/utils/supabase/client";// this is the client with ssr as mentioned aboveconstsupabase=createClient();const{ data, error }=awaitsupabase.from("tb_worker").select();console.log("🚀 ~ getData ~ error:\n",error);
Errors in the console when I try to request for the data
{
"code": "42P01",
"details": null,
"hint": null,
"message": "relation \"public.tb_worker\" does not exist"
}
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Create a sample nextjs project with supabase from the docs
Download sample database types for any project with custom schema.
Update either the browser client or the server client with the custom schema like this
import{createBrowserClient}from"@supabase/ssr";import{Database}from"../types/database";exportconstcreateClient=()=>createBrowserClient<Database>(process.env.NEXT_PUBLIC_SUPABASE_URL!,process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,{db: {schema: "tasks",// I'm using custom schema named tasks. You can change it to your schema name},});
At this stage, you'll get typescript errors.
You can still try to query for the data from the custom schema and will get the same errors.
import{createClient}from"@/utils/supabase/client";// this is the client with ssr as mentioned aboveconstsupabase=createClient();const{ data, error }=awaitsupabase.from("tb_worker").select();console.log("🚀 ~ getData ~ error:\n",error);
Expected behavior
Should get the data. It works perfectly with the supabase js library. Example: page.tsx
I've checked wherther it's an issue of Typescript types generated by the database type generation in the supabase dashboard. Maybe this bug is also related to that as well.
The text was updated successfully, but these errors were encountered:
I have the same problem, somebody knows the solution?
@somesebastian
I have a solution. I created separate clients for each schema. Used any as the type to stop typescript errors. You can modify the database.ts file that you can generate from the supabase dashboard. But it is tedious so I skipped it.
This doesn't seem the best solution but it works for now.
I have the same problem, somebody knows the solution?
@somesebastian I have a solution. I created separate clients for each schema. Used any as the type to stop typescript errors. You can modify the database.ts file that you can generate from the supabase dashboard. But it is tedious so I skipped it.
This doesn't seem the best solution but it works for now.
@anindosarker I'll test it, thank you for the solution!
Bug report
Describe the bug
I tried creating a client with my custom schema named
tasks
. But it throws errors and doesn't work.Errors in the editor
Code for the request:
Errors in the console when I try to request for the data
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
Should get the data. It works perfectly with the supabase js library. Example:
page.tsx
System information
Additional context
I've checked wherther it's an issue of Typescript types generated by the database type generation in the supabase dashboard. Maybe this bug is also related to that as well.
The text was updated successfully, but these errors were encountered: