viator
viator

Reputation: 1472

Slick 2.x filter by mapped column type (java.util.Date)

I'm using java.util.Date in my model case class. Since Slick doesn't support j.u.Date out of the box, I added implicit mapping like so implicit val dateColumnMapper = MappedColumnType.base[Date, SqlDate](d => new SqlDate(d.getTime), d => d) to my Table class.

But now I'm stuck with filtering by date field: proposalsQuery.filter(_.since >= since). I tried different options but always get compilation errors: value >= is not a member of scala.slick.lifted.Column[java.util.Date]

Since, I'm new in Scala/Slick working examples with simple explanation of the problem would be highly appreciated.

Thanks!

Upvotes: 3

Views: 814

Answers (2)

viator
viator

Reputation: 1472

implicit mapper MUST be available at the place where you write your filter query.

Upvotes: 3

Ionut
Ionut

Reputation: 486

you should import this in your file

import com.github.tototoshi.slick.JdbcJodaSupport._

and this is the library "com.github.tototoshi" %% "slick-joda-mapper" % "1.2.0"

Upvotes: 0

Related Questions