Scala codegen issue for column default value and mapped type

Skip to first unread message

Satyagraha 1956

May 17, 2020, 8:15:08 AM5/17/20
to Slick / ScalaQuery
I've got a Postrgres not null varying character column which I am hoping to map to a simple type-safe wrapper type, e.g. case class CustomerId(value: String). However the database column has been set up with a default value, e.g. "000000" which I cannot change. The generated code source for the associated row case class however generates something like case class SalesRow(..., customerId: CustomerId = "000000", ...) and this clearly will generate a compile error as the base and wrapped type are not the same. The row column type is right, just not the Scala default value. So, as I specifically do not want to write any auto-conversion from String to CustomerId, what's the best way forward?

I presume the correct solution is to override the row member generation process somehow, to have the column default value wrapped in the wrapper class, but I haven't found it particularly straightforward to see how to do that. Any functioning example would be most welcome. Actually, I think this is arguably a bug or at least an oversight.

Alternatively, a way to suppress the generation of the Scala default value entirely would be acceptable, as I can easily work around that in my Scala code.

Thanks for any input!


May 17, 2020, 9:14:08 AM5/17/20
For providing the default I would go for Scala option and while wrapping the value I will do getOrElse (default value).

Let me know if this works for you.


You received this message because you are subscribed to the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages