© 2026 Hedgehog Software, LLC

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

RLS and auth.uid()

Hey guys, I'm trying to figure out the following please:

When I enable the following policy for a table (security_group_assignment) on SELECT,
(auth.uid() = profile_id)
(auth.uid() = profile_id)


When I select data from that table and include a column from another table such as:
SELECT security_group.name, security_group_assignment.id, security_group_assignment.profile_id
FROM security_group_assignment JOIN security_group
ON security_group.id = security_group_assignment.security_group_id
WHERE security_group.name = 'variablename'
SELECT security_group.name, security_group_assignment.id, security_group_assignment.profile_id
FROM security_group_assignment JOIN security_group
ON security_group.id = security_group_assignment.security_group_id
WHERE security_group.name = 'variablename'


I would expect to ONLY get back the rows that match the security_group.name AND match the calling users UID with the profile_id.

However, even when the name doesn't match, I get back a row with the following data?
{
id: 2
profile_id: "28fsd-0a9a-Pfadsf-98dc-1490b9725a80"
security_group: null
{
id: 2
profile_id: "28fsd-0a9a-Pfadsf-98dc-1490b9725a80"
security_group: null


If the security_group is null, why is it even returning that row?? I would expect this to return no rows.

Here is the supabase client call:
  const { data, error } = await supabase
    .from("security_group_assignment")
    .select(`security_group ( name ), id, profile_id`)
    .eq("security_group.name", securityGroupName);
  const { data, error } = await supabase
    .from("security_group_assignment")
    .select(`security_group ( name ), id, profile_id`)
    .eq("security_group.name", securityGroupName);
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

RLS policy including a auth.uid() statement
SupabaseSSupabase / help-and-questions
3y ago
auth.uid() question
SupabaseSSupabase / help-and-questions
8mo ago
RLS and Updating without auth
SupabaseSSupabase / help-and-questions
8mo ago
Title: auth.uid() NULL issue with RLS enabled - Project ID: enzrjbcoxqtnxirlthps
SupabaseSSupabase / help-and-questions
8mo ago