Did anyone succeed in using Slick (I am currently using 3.0.0-RC3, the latest available version) to generate a table definition containing DB-specific functions? If so, how to achieve that?
Example: I have a column in Postgres with the following definition:
"request_date" timestamp default now(),
which I tried (unsuccessfully) describe in Slick DDL.
First attempt:
def requestDate = column[Option[DateTime]]("request_date", O Default "now()")
Of course, this was rejected:
[error] <path-to-file>: type mismatch;
[error] found : String("now()")
[error] required: Option[org.joda.time.DateTime]
[error] def requestDate = column[Option[DateTime]]("request_date", O Default "now()")
OK, I have tried to define a SimpleFunction (I already have DateTime converter in place):
val dbNow = SimpleFunction.nullary[DateTime]("now")
def requestDate = column[Option[DateTime]]("request_date", O Default dbNow)
which produced another error:
[error] <path-to-file>: type mismatch;
[error] found : slick.lifted.Rep[org.joda.time.DateTime]
[error] required: Option[org.joda.time.DateTime]
[error] def requestDate = column[Option[DateTime]]("request_date", O Default dbNow)
I have also tried SimpleLiteral[DateTime]("now()")
, which resulted in a similar error. (Removing Option did not help either).
Any ideas would be appreciated. It is a bit frustrating that such a simple thing does not seem to be easily available...