You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description and expected behavior
Given the following model schema:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
type FooMetadata {
isLocked Boolean
}
type FooOptionMetadata {
color String
}
model Foo {
id String @id @db.Uuid @default(uuid())
meta FooMetadata @json
}
model FooOption {
id String @id @db.Uuid @default(uuid())
meta FooOptionMetadata @json
}
zenstack generate will create an enhanced PrismaClient which incorrectly maps the type of FooOption.meta for prisma input types to FooMetadata instead of FooOptionMetadata. The result payload type correctly maps meta to FooOptionMeta.
Screenshots
Environment (please complete the following information):
ZenStack version: 2.11.6
Prisma version: 6.3.1
Database type: Postgresql
Additional context
Interestingly, renaming FooOption/FooOptionMetadata to Bar/BarMetadata seems to resolve the issue. So at first glance it seems something is breaking when the string Option is used?
I'd be happy to spend some more time investigating this issue, but would appreciate any advice the team has.
The text was updated successfully, but these errors were encountered:
diesal11
changed the title
JSON fields mapped to incorrect typedef in enhanced Prisma client
JSON fields map to incorrect typedef in enhanced Prisma client
Feb 20, 2025
Description and expected behavior
Given the following model schema:
zenstack generate
will create an enhanced PrismaClient which incorrectly maps the type ofFooOption.meta
for prisma input types toFooMetadata
instead ofFooOptionMetadata
. The result payload type correctly mapsmeta
toFooOptionMeta
.Screenshots
Environment (please complete the following information):
Additional context
Interestingly, renaming
FooOption
/FooOptionMetadata
toBar
/BarMetadata
seems to resolve the issue. So at first glance it seems something is breaking when the stringOption
is used?I'd be happy to spend some more time investigating this issue, but would appreciate any advice the team has.
Repo which reproduces the bug:
https://github.com./diesal11/zenstack-json-type-bug
The text was updated successfully, but these errors were encountered: