opened 11:09PM - 17 Jan 22 UTC
issue: bug
severity: medium
status: confirmed
source: core:database
## Bug Report
### Describe the bug
When try to filter by a relational field or… media type field is null or not Strapi throws error: `Only $and, $or and $not can by used as root level operators. Found $null.`
### Steps to reproduce the behavior
1-) Create a collection type (let's say `foo`) that contains a relation with another collection type (let's say `bar`)
(or alternatively Create a collection type (let say `foo`) that contains a media type field (let's say `bar`))
2-) Send a **GET** request to the `/foos?populate=*&filters[bar][$null]=true`
3-) API returns 500 Internal Server Error and Strapi console logs the following message:
> Only $and, $or and $not can by used as root level operators. Found $null.
### Expected behavior
On the earlier versions of Strapi (v3) there was support to filter by a relational field is null or not with a similiar query.
### System
Node.js version: v14.18.2
NPM version: v6.14.15
Strapi version: tried from v4.0.0 to v4.0.4
Database: Postgresql 10
Operating system: macOS v11.6