Use @map'ed enum values as TS enum values
Problem
Problem Consider the following schema: [code block] In database, it works as expected, the enum name and values are taken from the `@map` and `@@map` directives. In TypeScript, however, the generated values are as follows: [code block] Which is a problem, because every time you want to serialize the object returned from the database by prisma, you have to remap these values to the ones that the project uses (which is the database version). A simplified example would look like this: [code block] It gets much worse when there are nested includes. Suggested solution If explicitly defined, use values from `@map` directives as enum values, like so: [code block]
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Use @map'ed enum values as TS enum values
It's a serious problem and it's been a year and still not fixed. 😭
Trust Score
4 verifications
- 1
It's a serious problem and it's been a year and still not fixed. 😭
It's a serious problem and it's been a year and still not fixed. 😭
Validation
Resolved in prisma/prisma GitHub issue #8446. Community reactions: 7 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep