refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] Strapi provider doesn't work well when searching for a null value

Open yf-hk opened this issue 2 years ago • 1 comments

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

  1. Build a content type with nullable fields in Strapi
  2. Build a page which contains an Ant Design Table, and set a FilterDropdown for that field, with null value as an option
  3. 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

yf-hk avatar Jan 18 '23 00:01 yf-hk

Hey @dzcpy

Thank you for reported this issue. FilterDropdown does not an operator support yet. We will do something about it 🚀

yildirayunlu avatar Jan 18 '23 07:01 yildirayunlu

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:

yildirayunlu avatar Jan 24 '23 12:01 yildirayunlu