Api filtering null values

Hi everyone!

I am trying to filter all the records that have null value on a specified field. For instance all the Workflows where the Name is null.

As mentioned on the documentation the value for null filters must be added like: "name": {"$is_null": ""}}

But from many tests I've done a year ago this wasn't enough to get all the records and we needed to add an "equals to empty string" criteria to make it work. That said the correct request would look like:

"$or": [
{
"name": { "$is_null": ""}
},
{
"name": {"$equals": ""}
}
]

 

Recently when I tested on the Bugs module with the filter: "Hours_To_Resolution IS NULL" I got 0 records.

Api request: 

{
  "filter": [
    {
      "$or": [
        { "hours_to_resolution": { "$is_null": "" } },
        { "hours_to_resolution": { "$equals": "" } }
      ]
    }
  ],
  "max_num": "1000",
  "fields": "id,name,hours_to_resolution"
}

To fix this I needed to revert adding the criteria:
{ "hours_to_resolution": { "$equals": "" } }

Now, the correct request is:
{
  "filter": [
    {
      "hours_to_resolution": { "$is_null": "" }
    }
  ],
  "max_num": "1000",
  "fields": "id,name,hours_to_resolution"
}



Could someone please confirm what is the correct way of handling the IS NULL for all datatypes?
Has anything changed and is not reflected on the documentation or Changelogs?
Does it change depending on the data type of the field?

Thank you!
 
Parents Reply Children
No Data