Skip to content

Chaining Multiple .or() Filters with referencedTable Returns No Results (Works Individually) #1122

Closed
@Muneeb-Shah

Description

@Muneeb-Shah

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When chaining multiple .or() filters with referencedTable on different joined tables, the query returns no results despite individual filters working correctly. The combined filters appear to use AND logic instead of OR.

To Reproduce

// Base query
const query = supabase
  .from('calls')
  .select(`
    *,
    contact:contact_id!inner(full_name),
    batch:batch_id!inner(property:property_id!inner(suburb))
  `, { count: 'exact' })

// Working individual filter 1
query.or(`full_name.ilike.*test*`, { referencedTable: 'contact_id' })

// Working individual filter 2 
query.or(`suburb.ilike.*test*`, { referencedTable: 'batch_id.property_id' })

// Broken when combined
query
  .or(`full_name.ilike.*test*`, { referencedTable: 'contact_id' })
  .or(`suburb.ilike.*test*`, { referencedTable: 'batch_id.property_id' })
  1. Execute query with either individual .or() filter - returns matching rows
  2. Chain both .or() filters together - returns empty result set
  3. No errors are thrown, but results suggest implicit AND combination

Expected behavior

The query should return rows matching either:

  • contact.full_name contains search term, OR
  • property.suburb contains search term

System information

  • OS: macOS Sequoia Version 15.4.1
  • Browser: Chrome 136
  • Version of supabase-js: 2.49.4
  • Version of Node.js: 22.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions