New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not use multiple filters/deeps #13252
Comments
This technically should be resolved in #8909, but it does seems like currently it's malformed.
Thanks for reporting this. In the meantime, you can opt to use the json syntax to ensure it works properly 👍 |
Thank you for your quick response. The Json syntax works for us :) |
The and syntax works for filters but it does not work for deep. gives the error:
|
You should use any of the query parameters inside So if the relational field is called |
@azrikahar is it possible to form just this filter, with a nested |
Would you mind explaining what is "this filter" here? That is an example of a malformed filter that should not work 🤔 if you meant nested |
Thanks for clarifying, I was trying exactly the malformed filter and hoped it would work. Are there any plans to allow nesting |
Not as of now. The most recent related discussion would be #13203, but you can also open a more specific feature request if you'd prefer to.
It should still be possible to use |
Using this example I'm trying to establish a filter that returns every customer which has a product that is called "butter" and has a price "1". So naturally I would filter something like this: {
"_and": [
{
"products_id": {
"name": {
"_contains": "Product C"
}
}
},
{
"products_id": {
"price": {
"_eq": "100"
}
}
}
]
} But if the customer has one product that is not "butter" but has a price of "1" and the customer has another product "butter" but it is more/less expensive (price !=== "1"), it will still return the customer. To establish this, all I can think of is a query like this: {
"products_id": {
"_and": [
{
"name": {
"_contains": "Product C"
}
},
{
"price": {
"_eq": "100"
}
}
]
}
} But I may be missing something... |
I think it is technically working as intended (I could be wrong!) in the sense that they are indeed customers with "butter" and price "1" (once again not the type of "and" we're looking for here), hence the nesting/level matters like you mentioned. This isn't the exact desired result, but we can at least ensure the "products" m2m field returns empty array when we use So we can then do an array filter based on that. Understandably that's still not ideal, however I myself am not 100% if it's fully possible as well. |
It looks likes this bug is not resolved in 9.21 The tables:
The following filter on a preset on table
filters as if |
Linear: ENG-256 |
Describe the Bug
Making a REST request with 2 or more filters/deeps on a datamodel having "many-to-many" relation fails.
Using a single filter/deep works perfectly fine.
To Reproduce
Create the following collections with many-to-many relation (between customers and products in this case)
add a few products to each of the customers
make a rest call with filters on the many-to-many field
for e.g.
Errors Shown
What version of Directus are you using?
9.10.0
What version of Node.js are you using?
16.15.0
What database are you using?
Postgres 13.5
What browser are you using?
postman
How are you deploying Directus?
running locally
The text was updated successfully, but these errors were encountered: