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))
}
Sameif 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)
}
Actual behavior
java.util.NoSuchElementException: null is not a member of ValueEnum (warning, info) (ValueEnum.scala:58)
Could it be that we need to specify some custom decoder / encoder to handle options / null values?
This template isn't a strict requirement to open issues, but please try to provide as much information as possible.
Version: (e.g.
2.5.4
)Module: (e.g.
quill-jdbc
)Database: (e.g.
mysql
)Steps to reproduce the behavior
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 :
Sameif I do a
leftJoin
to a table that holds anEnum
in it, e.g.:Actual behavior
Could it be that we need to specify some custom decoder / encoder to handle options / null values?
I asked the question here too lloydmeta/enumeratum#256 but they don't seem to have an answer.
@getquill/maintainers
The text was updated successfully, but these errors were encountered: