© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•9mo ago•
25 replies
Strange

Joined table filter includes null values

encountering a super odd case here:

I'm trying to check an equality across a referenced table.

My TS code is as follows, and I'll provide the table definitions in a moment:

const { data: { user } } = await supabase.auth.getUser();

// ... various checks, user will always be defined from here on

const { data: access, error: getAccessError } = await supabase
  .from("access_control_list")
  .select("staff_id(linked_user_id), role_id(*)")
  .eq("staff_id.linked_user_id", user.id)
  .maybeSingle()
const { data: { user } } = await supabase.auth.getUser();

// ... various checks, user will always be defined from here on

const { data: access, error: getAccessError } = await supabase
  .from("access_control_list")
  .select("staff_id(linked_user_id), role_id(*)")
  .eq("staff_id.linked_user_id", user.id)
  .maybeSingle()


The above query will return results where
staff_id.linked_user_id
staff_id.linked_user_id
is null, not strictly equal to
user.id
user.id
. I have had to specifically add
.not("staff_id", "is", null)
.not("staff_id", "is", null)
to the query chain to make it return only where linked_user_id equals the user's 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

How to filter on joined table
SupabaseSSupabase / help-and-questions
4y ago
Filter original records, given a joined table
SupabaseSSupabase / help-and-questions
14mo ago
How to use .or() filter with joined table columns in Supabase?
SupabaseSSupabase / help-and-questions
4mo ago
Filter query unless filter param is null
SupabaseSSupabase / help-and-questions
4y ago