I have a very strange problem that is driving we up the walls. I am creating the following table
CREATE TABLE articles(
id BIGINT generated by default as IDENTITY PRIMARY KEY,
user_id uuid references auth.users NOT NULL,
title TEXT,
CONTENT TEXT,
user_email TEXT,
inserted_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::TEXT,NOW()) NOT NULL
);
ALTER TABLE articles ENABLE ROW LEVEL SECURITY;
CREATE policy "users can create articles" ON articles for
INSERT WITH CHECK(auth.uid() = user_id);
CREATE policy "users can update their own articles" ON articles for
UPDATE USING (auth.uid() = user_id);
CREATE policy "users can delete their own articles" ON articles for
DELETE USING (auth.uid() = user_id);
CREATE policy "users can read their own articles" ON articles for
SELECT USING (auth.uid() = user_id);
I can add data to it through my front-end with:
const { data, error } = await supabaseClient.from("articles").insert(
[{
title: title,
content: content,
user_email: user?.email?.toLowerCase(),
user_id: user?.id,
}]
).single()
and that works. I can verify on supabase that the row has indeed been added.

However, I can't access my data through the front-end since the expression: auth.uid() = user_id seems to evaluate to false even though it is the same. If I disable Row level security or write TRUE instead everything works as intended.

Can you use Typecast, it seems to work for me earlier.
CHECK(auth.uid()::text = user_id::text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With