Map PSQL enum with Kotlin enum #1046
Answered
by
nakamura-to
Distractic
asked this question in
Q&A
-
Hello ! I'm trying to map a column with an enum property. Kotlin classes: public enum class Rank {
PLAYER,
ADMIN
}
@KomapperEntity
@KomapperTable("player")
public data class Player(
@KomapperId
val uuid: UUID,
val rank: Rank,
) SQL file: CREATE TYPE rank AS ENUM ('PLAYER', 'ADMIN');
CREATE TABLE player
(
uuid uuid PRIMARY KEY,
rank rank NOT NULL
); Gradle KSP arguments: ksp {
arg("komapper.enumStrategy", "name")
} However, I have this error when I'm trying to insert:
So how can I map my Kotlin enum with my PSQL enum ? Thanks in advance |
Beta Was this translation helpful? Give feedback.
Answered by
nakamura-to
Oct 13, 2023
Replies: 1 comment 11 replies
-
The database enum type is currently not supported. However, we would like to consider supporting that in the future. @KomapperEntity
@KomapperTable("player")
public data class Player(
@KomapperId
val uuid: UUID,
@KomapperEnum(EnumType.ENUM)
val rank: Rank,
) |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
R2dbcDatabase
can receive aPostgresqlConnectionFactory
.Try the following code: