omar-dulaimi / prisma-zod-generator

Prisma 2+ generator to emit Zod schemas from your Prisma schema
MIT License
535 stars 45 forks source link

nullable is reversed on json type #91

Closed ygreenb closed 9 months ago

ygreenb commented 9 months ago

Bug description

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

How to reproduce

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

schema.prisma

model User {
  bio  Json?
}

then run prisma migrate dev

prisma/generated/zod/index.ts

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

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

schema.prisma

model User {
  bio  Json
}

then run prisma migrate dev

prisma/generated/zod/index.ts

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

Expected behavior

No response

Prisma information

schema.prisma

model User {
  bio  Json?
}

Environment & setup

Prisma Version

5.1.1