drift icon indicating copy to clipboard operation
drift copied to clipboard

Filter : isIn a List with null value

Open ad-angelo opened this issue 1 week ago • 0 comments

Hi,

I am trying to filter rows on a nullable IntColumn by using isIn() function. The list I want to match can contains null value.

However, isIn() function only accept List of non nullable Int. (Compiler error : The argument type 'List<int?>' can't be assigned to the parameter type 'Iterable<int>')

Code example :

IntColumn get foo => integer().nullable()
--------
db.managers.rows.filter((f) => f.foo.isIn([1,2,3,null]) // Not working : compiler error

I found a workaround by making :

if(filterList.contains(null)){
   (f.foo.isNull() | f.foo.isIn(filterListWithoutNull))
} else {
   f.foo.isIn(filterList)
}

Thanks for your help !

ad-angelo avatar Dec 14 '25 00:12 ad-angelo