Prisma WhereUniqueInput typings within node_modules are incorrect/broken
See original GitHub issueBug description
Prisma’s typings in node modules for the update function (UserScoresWhereUniqueInput) are wrong. It isn’t including everything from my schema, only the id.
I have attempted to reinstall prisma, completely remove the node_modules, and run npx prisma generate
again, but none of them succeeded in updating the typings correctly. The schema in the database looks correct, just not in the typings.
How to reproduce
Generate a prisma schema, put something similar to
model UserScores {
id Int @id @default(autoincrement())
guildId String
userId String
globalPoints Int
weeklyPoints Int
}
in it, and try npx prisma generate. The d.ts file in .prisma where it says UserScoresWhereUniqueInput should only include the id.
Expected behavior
I expect UserScoresWhereUniqueInput to contain the rest of the things on the model, like guildId and userId.
Prisma information
Full schema:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model settings {
id Int @id @default(autoincrement())
guildId String
prefix String
}
model userScores {
id Int @id @default(autoincrement())
guildId String
userId String
globalPoints Int
weeklyPoints Int
}
Database query that is erroring (typescript)
await prisma.userScores.update({
where: {
userId: message.author.id,
guildId: message.guild!.id,
},
data: {
globalPoints: 0,
},
});
Environment & setup
- OS: Windows 10
- Database: Postgresql
- Node.js version: v14.16.0
- Prisma version:
prisma : 2.22.0
@prisma/client : 2.22.0
Current platform : windows
Query Engine : query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine : migration-engine-cli 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 60cc71d884972ab4e897f0277c4b84383dddaf6c
Studio : 0.379.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:16 (5 by maintainers)
Top Results From Across the Web
prisma argument of type whereuniqueinput needs at least one ...
But I have a hard time with where selector in Prisma. ... prisma/prismaPrisma WhereUniqueInput typings within node_modules are incorrect/broken#6953.
Read more >Advanced type safety (Reference) - Prisma
Prisma Client provides full type safety for queries, even for partial queries or included relations. This page explains how to leverage the generated...
Read more >Nest js + prisma project, error in findUnique method in services
I tried locally and typing email as string works with findUnique without error. Can you please update your question to include how you...
Read more >Prisma | NestJS - A progressive Node.js framework
Note The prisma generate command reads your Prisma schema and updates the generated Prisma Client library inside node_modules/@prisma/client . Use Prisma Client ...
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
If you do not have a unique guarantee on the field you want to filter for, you need to use
deleteMany
orupdateMany
and it should let you filter as you are trying to.@janpio
I have colleagues that asked me the same question. I think it is perfectly fine to use
updateMany
if we dont useuniqueWhere
, one DX improve can be adding a suggestion/tip saying: