question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect Include typings when having models called `X` and `XUpdate`

See original GitHub issue

Bug description

When having two models called X and XUpdate, the generated types for include parameters of XUpdate are incorrect.

How to reproduce

Example (only relevant fields included):

model Product {
  id      String          @id @default(uuid())
  updates ProductUpdate[] @relation(name: "ProductUpdates")
}

model ProductUpdate {
  id        String  @id @default(uuid())
  productId String
  product   Product @relation(name: "ProductUpdates", fields: [productId], references: [id])
}

Then, when querying another model that has a relation with ProductUpdate:

prisma.orderItem.findUnique({
  where: {
    id,
  },
  include: {
    productUpdate: {
      include: {
        product: true,
      },
    },
  },
})

I get the following error:

Screenshot 2021-06-08 at 10 15 54

Looking at the generated types, this seems to be because the productUpdate field in OrderItemInclude has type ProductUpdateArgs, which are the arguments for an update operation on a Product model, instead of the args without action of the ProductUpdate model.

Screenshot 2021-06-08 at 10 16 41 Screenshot 2021-06-08 at 10 18 47

Expected behavior

The type of OrderItemInclude.productUpdate should be related to the ProductUpdate model, not the Product model. Consequently there should not be a type error in this situation.

Prisma information

Relevant prisma schema provide above.

Environment & setup

  • OS: macOS
  • Database: PostgreSQL
  • Node.js version: 15.14.0

Prisma Version

Environment variables loaded from .env
@prisma/cli          : 2.13.1
@prisma/client       : 2.13.1
Current platform     : darwin
Query Engine         : query-engine fcbc4bb2d306c86c28014f596b1e8c7980af8bd4 (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli fcbc4bb2d306c86c28014f596b1e8c7980af8bd4 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core fcbc4bb2d306c86c28014f596b1e8c7980af8bd4 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt fcbc4bb2d306c86c28014f596b1e8c7980af8bd4 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Studio               : 0.329.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pantharshit00commented, Aug 1, 2021

Sorry for the late reply here. This got buried in my notifications.

I can confirm the conflict and marking this as candidate.

1reaction
ianmartorellcommented, Jul 16, 2021

No problem, thank you for the quick reply 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to overwrite incorrect TypeScript type definition installed ...
How to overwrite incorrect TypeScript type definition installed via @types/package · You can just add a new interface with the same name as...
Read more >
compareGroups 4.0: Descriptives by groups - R Project
Since version 4.0, a new function called descrTable has been implemented which ... Error in compareGroups.fit(X = X, y = y, include.label =...
Read more >
A Study of Typing-Related Bugs in JVM Compilers
By examining 320 typing-related bugs, we provide an in-depth analysis on diverse aspects, including bug symptoms, root causes, bug fixes, and test case ......
Read more >
Logic Pro release notes - Apple Support
Smart Tempo detection has been improved. There are new key commands in the Smart Tempo Editor, including Toggle Track/Master View, Cycle Through ...
Read more >
Introduction to Small Area Estimation Techniques
Please contact pubsmarketing@adb.org if you have questions or comments with respect to content, ... 4.3 Small Area Estimation Using Regression-Based Models.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found