© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
4 replies
drewbie

RLS Policy With Join

Trying to follow along the docs with how to create an RLS policy with joins but cant seem to figure it out. I have
cart_items
cart_items
which have a
product_id
product_id
and an
account_id
account_id
. the Products table also has an
account_id
account_id
.

I am trying to create an RLS policy on insert so that you cannot add your own products to your cart but this doesn't seem to work. What am I missing :mind_blow_astonished: . Appreciate the help!

create policy "Cart items cannot be added for cart account's products"
  ON public.cart_items for INSERT
  to authenticated
  WITH CHECK (
    not exists (
      select 1 from products
      where products.account_id = account_id
    )
  );
create policy "Cart items cannot be added for cart account's products"
  ON public.cart_items for INSERT
  to authenticated
  WITH CHECK (
    not exists (
      select 1 from products
      where products.account_id = account_id
    )
  );
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Simple RLS Policy with Join
SupabaseSSupabase / help-and-questions
4y ago
Writing RLS policy with join
SupabaseSSupabase / help-and-questions
4y ago
RLS policy with join not working
SupabaseSSupabase / help-and-questions
4y ago
RLS Policy
SupabaseSSupabase / help-and-questions
4mo ago