Hi! Supabase newb here. 🙂 I created a table from ...
# help
d
Hi! Supabase newb here. 🙂 I created a table from a CSV file which worked perfectly. Querying this table via JS or cURL doesn't work, meaning nothing gets returned. When I create a new test table manually and add a row, the query works. What am I missing?
s
Check if that table has Row Level Security (RLS) turned on, also can you elaborate more on what you mean by doesn't work and nothing gets returned.
d
thx! yes, RLS is activated. The cURL returns an empty list ('[]').
s
Do you have any RLS policies set up?
d
I just enabled RLS on the test table and now it also returns an empty list.
no
s
Yes that is because by default when RLS is enabled all queries will be blocked, so you have to create policies for SELECT in order to get data
You can create a policy and just set the value to true for it to return data to anyone, if the intended role of that table is to allow anyone to view this data
d
ok, I see
it works when I open it up, so that is great.
I tried this:
CREATE POLICY "t4" ON public.test FOR SELECT USING (auth.role() = 'authenticated');
which mimics the insert one but with the operation select
doesn't work but this is probably more my mssing SQL skills and not a Supabase problem
s
That would only work if you have a user who is logged in
d
can I mimic a logged in user with cURL?
s
I'm not sure how you would do this with cURL
I guess you would need to send over a JWT with the cURL request that would let the server know that the use had been authenticated. Do a search on the Supabase GitHub discussions ad I think this may have been covered there before.
d
I put my current findings into this CodePen: https://codepen.io/dirkk0/pen/LYzbbZp?editors=1010 Something like this would have been the plain vanilla example that I was looking for.
Everything is working now, thanks for your help.