15
votes

How do I filter rows in Slick if a column is null?

val employees = Queryable[Employees]

// Error
val query = employees.filter( _.terminationDate == Nil )

Might be important to note that

terminationDate: Option[String]

I am using Direct Embedding.

1

1 Answers

25
votes

Slick has its own why of checking for null values in a column:

val query = employees.filter(_.terminationDate.isNull)

The opposite is isNotNull.

Or in newer versions of Slick:

val query = employees.filter(_.terminationDate.isEmpty)

and

val query = employees.filter(_.terminationDate.isDefined)