Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Match at least one filter not working as expected #428

@nCrafts

Description

@nCrafts

Describe the bug

I am trying to use the .or method to match at least one filter. It works with strings and also json objects, but doesn't seem to work for json arrays. However the syntax does work with the .filter method.

To Reproduce

I have a table table_name with a jsonb column named data. The content of this column is:

{
  "one": {
    "value": [
      {
        "label": "Red",
        "value": "red"
      }
    ]
  },
  "two": {
    "value": [
      {
        "label": "Green",
        "value": "green"
      }
    ]
  }
}

This query works as expected, fetching the one row:

let two = await supabase
.from("table_name")
.select("*")
.filter("data->one->value", "cs", '[{"label":"Red","value":"red"}]');
console.log(two);

However this query fails with an error:

let one = await supabase
.from("table_name")
.select("*")
.or('data->one->value.cs.[{"label":"Red","value":"red"}]');
console.log(one);

Error being:

{"code":"PGRST100","details":"unexpected \":\" expecting \"->>\", \"->\" or delimiter (.)","hint":null,"message":"\"failed to parse logic tree ((data->one->value.cs.[{\"label\":\"Red\",\"value\":\"red\"}]))\" (line 1, column 47)"}

If I replace the .or with this I no longer see an error, but it also doesn't fetch a row:

.or('data->one->value.cs.{"label":"Red","value":"red"}');

Expected behavior

I'd like to be able to use match one filter (or perhaps match all filters) with an array of objects. Something like:

let one = await supabase
.from("table_name")
.select("*")
.or('data->one->value.cs.[{"label":"Red","value":"red"}], data->two->value.cs.[{"label":"Green","value":"green"}]');
console.log(one);

System information

  • OS: macOS
  • Version of supabase-js: 2.22.0
  • Version of Node.js: 19.7.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