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

No type validation when creating #418

Open
2 tasks done
rivatove opened this issue Nov 17, 2024 · 7 comments
Open
2 tasks done

No type validation when creating #418

rivatove opened this issue Nov 17, 2024 · 7 comments

Comments

@rivatove
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Versions

3.1.1

A minimal reproducible example

I'll add a minimal reproduction if it proves necessary.

Description

Hi, I'm experiencing no type checking when using Prisma's create method. This is really baffling as the generated type seem alright:

  export type ordersCreateInput = {
    ...
    meta?: PrismaJson._OrderMeta | NullableJsonNullValueInput
    ...
  }

In the method call however, I can assign any value I want to the meta field with no error:

this.prisma.orders
      .create({
        data: {
          ...
          meta: 10,
          ...
      })

Doing it this way will raise an error though:

const test: Prisma.ordersCreateInput['meta'] = 10;

Do you know what could it be?

Steps to Reproduce

I'll add a minimal reproduction if it proves necessary.

Expected Behavior

No response

@arthurfiorette
Copy link
Owner

I'll need a minimal reproduction repo to test it out :/

@rivatove
Copy link
Author

I'll need a minimal reproduction repo to test it out :/

https://github.com/rivatove/prisma-json-types-generator-418/blob/master/prisma/seed.ts

Type-checking doesn't work with:

previewFeatures = ["strictUndefinedChecks"]

I don't think it's the only reason as removing that flag doesn't seem to fix that in my production app, but it's a good start and we can iterate further when you look into that.

@arthurfiorette
Copy link
Owner

I fixed the strictUndefinedChecks problem with the latest release, would you mind testing it out again?

https://github.com/arthurfiorette/prisma-json-types-generator/releases/tag/v3.2.0

@rivatove
Copy link
Author

rivatove commented Dec 1, 2024

I fixed the strictUndefinedChecks problem with the latest release, would you mind testing it out again?

https://github.com/arthurfiorette/prisma-json-types-generator/releases/tag/v3.2.0

It seems Prisma client extensions cause the issue. See updated reproduction:
https://github.com/rivatove/prisma-json-types-generator-418/blob/master/prisma/seed.ts

@arthurfiorette
Copy link
Owner

Thanks for the reproduction steps, sadly I do not have time to fix this right now but i'd love to review a PR fixing this.

@rivatove
Copy link
Author

rivatove commented Dec 6, 2024

Understandable. I'm putting a $120 bounty for anyone that fixes this and has his PR merged and released. Valid until such functionality is not supported natively by Prisma.

2025-02-08 EDIT: I'm cancelling the bounty because I stopped using Prisma extensions.

@cu8code
Copy link

cu8code commented Dec 7, 2024

I'll work on this, let's me see if I can find a clever solution for this!

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

No branches or pull requests

3 participants