Reputation: 17933
Given a case class representation of a data row with a java.sql.Timestamp
:
case class ExampleRow(id: String, ts: Timestamp)
And query expecting an ExampleRow
:
import doobie._
import doobie.implicits._
import doobie.postgres.implicits._
val queryExampleRows =
sql"select * from example".query[ExampleRow].to[List]
There is a resulting compile error:
Cannot find or construct a Read instance for type:
ExampleRow
This is surprising given that the documentation claims that Timestamp should work. Further, I know that the Timestamp is the cause because removing that member results in the code compiling.
How can a case class contain a Timestamp and capable of being queried by doobie?
There is a similar question but I cannot figure out if it applicable to my question since it involves a type parameter T
and not a concrete type like Timestamp.
Thank you in advance for your consideration and response.
Upvotes: 0
Views: 474
Reputation: 17933
Per the suggestion from the comments the problem was solved by transitioning the type from java.sql.Timestamp
to java.time.Instant
.
Upvotes: 1