我已将一些 Postgresql 类型作为扩展添加到 Exposed。它有两个现成的类型,名为enumeration
和enumerationByName
。我对它们进行了测试,但没有成功将 postgre 枚举类型映射到 Kotlin 枚举类。在阅读和写作中都会引发错误
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
}
阅读时:
java.lang.IllegalStateException: open is not valid for enum TicketStatus