-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Mapped enums with create function seem to not work correctly #28591
Copy link
Copy link
Closed
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.trackedThis issue is internally tracked by the Prisma Team on Linear.This issue is internally tracked by the Prisma Team on Linear.
Milestone
Description
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("rejected")
@@map("SuggestionStatus")
}
And a create request for it in a test:
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
If you have any insight I would appreciate it.
Severity
🔹 Minor: Unexpected behavior, but does not block development
Reproduction
Expected vs. Actual Behavior
I expected the above syntax to work, since this matches the requirement from the typing system.
Frequency
Consistently reproducible
Does this occur in development or production?
production
Is this a regression?
Workaround
Mapping to name in the code using a reverse mapping with a type cast.
Prisma Schema & Queries
enum SuggestionStatus {
PENDING @map("pending")
ACCEPTED @map("accepted")
REJECTED @map("rejected")
@@map("SuggestionStatus")
}
model SuggestionModel {
id Int @id @default(autoincrement())
suggestedContent String x @map("suggested_content")
status SuggestionStatus @default(PENDING)
@@index([status])
@@map("snippet_suggestions")
}
// Add relevant Prisma Client queryPrisma Config
// This file was generated by Prisma and assumes you have installed the following:
// npm install --save-dev prisma dotenv
import "dotenv/config";
import { defineConfig, env } from "prisma/config";
export default defineConfig({
schema: "src/prisma/schema.prisma",
migrations: {
path: "src/prisma/migrations",
},
datasource: {
url: env("DATABASE_URL"),
},
});Logs & Debug Info
// Debug logs here
Environment & Setup
- OS: macOs
- Database: PostgresQL
- Node.js version: v24.11.0
Prisma Version
prisma : 7.0.0
@prisma/client : 7.0.0
Operating System : darwin
Architecture : x64
Node.js : v24.11.0
TypeScript : 5.9.2
Query Compiler : enabled
PSL : @prisma/prisma-schema-wasm 6.20.0-16.next-0c19ccc313cf9911a90d99d2ac2eb0280c76c513
Schema Engine : schema-engine-cli 0c19ccc313cf9911a90d99d2ac2eb0280c76c513 (at node_modules/@prisma/engines/schema-engine-darwin)
Default Engines Hash : 0c19ccc313cf9911a90d99d2ac2eb0280c76c513
Studio : 0.8.0```
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.trackedThis issue is internally tracked by the Prisma Team on Linear.This issue is internally tracked by the Prisma Team on Linear.