This question has been asked and answered for slick 1 and 2, but the answers don't seem to be valid for slick 3.
Attempting to use the pattern in How to use Enums in Scala Slick?,
object MyEnumMapper {
val string_enum_mapping:Map[String,MyEnum] = Map(
"a" -> MyEnumA,
"b" -> MyEnumB,
"c" -> MyEnumC
)
val enum_string_mapping:Map[MyEnum,String] = string_enum_mapping.map(_.swap)
implicit val myEnumStringMapper = MappedTypeMapper.base[MyEnum,String](
e => enum_string_mapping(e),
s => string_enum_mapping(s)
)
}
But MappedTypeMapper
has not been available since slick 1, and the suggested MappedColumnType
for slick 2 is no longer available, despite being documented here.
What's the latest best practice for this?