I have added some Postgresql types to Exposed as extensions. It has two ready types named enumeration
and enumerationByName
. I tested both of them with no success for mapping a postgre enum type to Kotlin enum class. In both reading and writing it raises error
enum class TicketStatus(val status: String) {
Open("open"),
Close("close"),
InProgress("in_progress")
}
class Ticket(id: EntityID<UUID>) : Entity<UUID>(id) {
companion object : EntityClass<UUID, Ticket>(Tickets)
var geom by Tickets.geom
var description by Tickets.description
var status by Tickets.status
var createdAt by Tickets.createdAt
var updatedAt by Tickets.updatedAt
var owner by Tickets.owner
}
When reading:
java.lang.IllegalStateException: open is not valid for enum TicketStatus
open
,close
etc. or read some upper-cased names from the DB. – Traceytrachea