Incorrect Include typings when having models called `X` and `XUpdate`
See original GitHub issueBug 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:
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.
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:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry for the late reply here. This got buried in my notifications.
I can confirm the conflict and marking this as candidate.
No problem, thank you for the quick reply 😃