refine
refine copied to clipboard
[BUG] Strapi provider doesn't work well when searching for a null value
Describe the bug
Hi, I'm using Ant Design's Table and FilterDropdown to make a table filter. When there's empty value (null in strapi), it calls the strapi backend with http://localhost:1337/api/posts?filters[content][$eq]=null, which will cause Strapi a 500 error. For querying null value, it should use something like http://localhost:1337/api/posts?filters[content][$null]=true, or http://localhost:1337/api/posts?filters[content][$eq]=.
Is there any way to get around it?
An alternative way would be, set the filter to an empty string. However currently if the filter is empty string, it clears all searches
Steps To Reproduce
- Build a content type with nullable fields in Strapi
- Build a page which contains an Ant Design Table, and set a FilterDropdown for that field, with null value as an option
- Apply the filter with null value
Expected behavior
Strapi provider should handle null value searches without causing error
Screenshot
No response
Desktop
- strapi: 4.5.6
- @pankod/refine-strapi-v4: 3.39.6
- @pankod/refine-antd: 4.7.0
- @pankod/refine-core: 3.94.0
Mobile
No response
Additional Context
No response
Hey @dzcpy
Thank you for reported this issue. FilterDropdown does not an operator support yet. We will do something about it 🚀
We cannot do this with <FilterDropdown> as Antd does not support this way of filtering (https://github.com/ant-design/ant-design/issues/27331). However, I have a few suggestions for doing this:
- You can use TableSearch.
- You can use
setFiltermethod ofuseTable.