I'm trying to make a fuzzy search with the followi...
# help
v
I'm trying to make a fuzzy search with the following code on a table
products
that has a
many-to-many
relationship to
categories
so that
searchQuery
can be either an
ilike of product.name OR ilike of category.name
but I cannot figure out why it doesn't work
Copy code
ts
supabase()
  .from<ProductWithIngredients>('products')
  .select('*, ingredients(*), products_ingredients(*), categories(*)')
  .or(`name.ilike.%${searchQuery}%`)
  .or(`name.ilike.%${searchQuery}%`, { foreignTable: 'categories' })
  .throwOnError()
  .then((response) => (isNull(response.data) ? [] : response.data));
Any idea?
s
Maybe try using
categories!inner
as:
Copy code
js
supabase()
  .from<ProductWithIngredients>('products')
  .select('*, ingredients(*), products_ingredients(*), categories!inner(*)')  .or(`name.ilike.%${searchQuery}%`)
  .or(`name.ilike.%${searchQuery}%`, { foreignTable: 'categories' })
v
I've tried that already but it still won't work
It works if there is only a single or condition
It looks like the or condition get concatenated in a wrong way