Skip to content

Strong typed JSON fields don't support @default and generate invalid Zod schemas when they are a List #2039

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

Closed
diesal11 opened this issue Mar 12, 2025 · 0 comments · Fixed by #2040

Comments

@diesal11
Copy link
Contributor

Description and expected behavior

type Foo {
    a String
}

model Bar {
    id            String    @id   @default(cuid())
    foo          Foo       @json @default("{ \"a\": \"a\" }")
    fooList    Foo[]    @json @default("[{ \"a\": \"b\" }]")
}

@default args on Typed JSON fields currently fail with the error: Value is not assignable to parameter
However as per the Prisma docs, strings are the intended method to provide default JSON values.

Unrelated to that, the generated Zod schemas for Typed JSON lists like fooList are missing z.array(...), the typescript types are correct

Environment (please complete the following information):

  • ZenStack version: 2.12.2
  • Prisma version: 6.4.x
  • Database type: Postgresql

Additional context

Raising a PR to address this shortly, just needed an issue number for the regression test :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant