Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] nullable is reversed on json type #238

Open
ygreenb opened this issue Jan 31, 2024 · 0 comments · May be fixed by #240
Open

[BUG] nullable is reversed on json type #238

ygreenb opened this issue Jan 31, 2024 · 0 comments · May be fixed by #240
Assignees
Labels
bug (unconfirmed) Could be a bug

Comments

@ygreenb
Copy link

ygreenb commented Jan 31, 2024

Describe the bug
In Prisma schema, I defined a field as a Json nullable type, but the generated result from Zod is not nullable.

Screenshots

column is not nullable in prisma schema, but the generated type is not nullable

schema.prisma

model User {
  name String?
  bio  Json?
}

then run prisma migrate dev

prisma/generated/zod/index.ts

export const UserSchema = z.object({
  name: z.string().nullable(),
  bio: JsonValueSchema,
})

column is nullable in prisma schema, but the generated type is nullable

schema.prisma

model User {
  name String
  bio  Json
}

then run prisma migrate dev

prisma/generated/zod/index.ts

export const UserSchema = z.object({
  name: z.string(),
  bio: JsonValueSchema.nullable(),
})

Package versions (please complete the following information):

  • zod: 3.21.4
  • prisma: 5.1.1
  • zod-prisma-types: 3.1.6

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unconfirmed) Could be a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants