You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using enumeratum successfully when dealing with enum values, both with Circe and with Quill. We define something like this:
sealed abstract class TopicType(val value: String) extends StringEnumEntry
object TopicType extends StringEnum[TopicType] with StringCirceEnum[TopicType] with StringQuillEnum[TopicType] {
object Info extends TopicType("info")
object Warning extends TopicType("warning")
val values: immutable.IndexedSeq[TopicType] = findValues
}
// case class representing our MySQL payload table
case class Payload(id: String, topic: TopicType)
and use Payload when decoding / encoding mysql and json using Quill and Circe. With Quill and MySQL this works fine with the following table:
create table payload(
id varchar(36) not null primary key,
topic_type enum ('info', 'warning') not null
)
However, I cannot for the life of me figure out how to make this work when using optional fields for our enumeratum type.
We want to be able to use the payload class like this:
case class Payload(id: String, topic: Option[TopicType])
When trying to use an optional topic and read from our database using Quill with :
...
run {
query[Payload].filter(payload => payload.id == lift(someId))
}
we get:
java.util.NoSuchElementException: null is not a member of ValueEnum (warning, info) (ValueEnum.scala:58)
Same thing happens if I do a leftJoin to a table that holds an Enum in it, e.g.:
case class Payload(id: String)
case class PayloadData(payloadId: String, topic: TopicType)
run {
query[Payload]
.leftJoin(query[PayloadData])
.on((p, pd) => p.id == pd.payloadId)
}
Could it be that we need to specify some custom decoder / encoder to handle options / null values?
The text was updated successfully, but these errors were encountered:
Hmm, I'm honestly not too sure about this one because I haven't used Quill with this lib myself. Can you try seeing if someone on the Quill side knows?
We're using enumeratum successfully when dealing with enum values, both with Circe and with Quill. We define something like this:
and use Payload when decoding / encoding mysql and json using Quill and Circe. With Quill and MySQL this works fine with the following table:
However, I cannot for the life of me figure out how to make this work when using optional fields for our enumeratum type.
We want to be able to use the payload class like this:
When trying to use an optional topic and read from our database using Quill with :
we get:
Same thing happens if I do a
leftJoin
to a table that holds anEnum
in it, e.g.:Could it be that we need to specify some custom decoder / encoder to handle options / null values?
The text was updated successfully, but these errors were encountered: