Match at least one filter not working as expected
nCrafts opened this issue · comments
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
Any news on that?
Did you find a workaround @nCrafts?