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.
import doobie.implicits.javasql._
java.sql.Timestamp
a deprecated class that should not be used for years? Usejava.time
whenever possible.