Problem with mapped enums in 7.0.0?

I have a mapped enum in my schema, something along the lines of:
enum SuggestionStatus {
PENDING @map("pending")
ACCEPTED @map("accepted")
REJECTED @map("rejected")

@@map("SuggestionStatus")
}
enum SuggestionStatus {
PENDING @map("pending")
ACCEPTED @map("accepted")
REJECTED @map("rejected")

@@map("SuggestionStatus")
}
And a create request for it in a test:
const enrichment = await prisma.suggestionModel.create({
data: {
...
status: SuggestionStatus.PENDING,
},
});
const enrichment = await prisma.suggestionModel.create({
data: {
...
status: SuggestionStatus.PENDING,
},
});
I'm getting the following error:
PrismaClientValidationError:
Invalid `prisma.suggestionModel.create()` invocation in ...
...
data: "pending"
...
Invalid value for argument `status`. Expected SuggestionStatus
PrismaClientValidationError:
Invalid `prisma.suggestionModel.create()` invocation in ...
...
data: "pending"
...
Invalid value for argument `status`. Expected SuggestionStatus
If you have any insight I would appreciate it.
4 Replies
Prisma AI Help
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the #ask-ai channel awaits if you're curious!
Nurul
Nurul2w ago
Was this working as expected in Prisma 6? I'll need to reproduce this and see what's the issue
Spyda
Spyda7d ago
Looks like there's a few people (including myself) reporting the issue. The current workaround is passing the "key value" of the ENUM into the methods instead of the ENUM themselves - E.g. in the above, passing the string literal"PENDING" in, instead of SuggestionStatus.PENDING works. https://github.com/prisma/prisma/issues/28591
GitHub
Mapped enums with create function seem to not work correctly · Iss...
Bug description I have a mapped enum in my schema, something along the lines of: enum SuggestionStatus { PENDING @map("pending") ACCEPTED @map("accepted") REJECTED @map("re...
donny
donny7d ago
I've just about finished the migration to v7 and i stumbled onto this enum ripper.. This is blocking us from moving forward with the upgrade. Yes this was working in Prisma 6
enum BookingCompletedStatus {
Completed @map("complete")
PatientCancel @map("patient_cancel")
PracticeCancel @map("practice_cancel")
NoShow @map("did_not_attend")
}
enum BookingCompletedStatus {
Completed @map("complete")
PatientCancel @map("patient_cancel")
PracticeCancel @map("practice_cancel")
NoShow @map("did_not_attend")
}

Did you find this page helpful?