I'm trying to use a Scala 2 enum with Quill, like so:
import io.getquill.MappedEncoding
object MyEnumType extends Enumeration {
type MyEnumType = Value
val ONE, TWO, THREE = Value
implicit val encode: MappedEncoding[MyEnumType, String] =
MappedEncoding(_.toString)
implicit val decode: MappedEncoding[String, MyEnumType] =
MappedEncoding(MyEnumType.withName)
}
But I'm ending up with an error from Postgres:
ERROR: operator does not exist: my_enum_type = character varying
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
I'm printing out the query using translate, and the query is generated like so:
WHERE column_1 = ONE
Where I'm expecting it to be rendered like:
WHERE column_1 = 'ONE'
What's the proper way to handle enums with Quill in Scala 2.13?
I have been experimenting, including using the Enumeratum library, and enum values are still not being generated correctly.
Using the debugger, I can see that the custom encoder is being evaluated, but the result value never makes it to the generated query.
I have posted an example of the problem on Gist at Test.scala.