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.

ManyToMany join table model generates empty inputs

See original GitHub issue

Bug description

When I define models with ManyToMany relation and separate join table (it’s happening when introspecting the existing database), Prisma client generates empty inputs for update many operations on that join table model:

Code_VlTwR7sKGR

Code_aInL85B5js

How to reproduce

Generate Prisma client from schema below.

Then try to make updateMany operation - you’re not allowed to pass any keys to data object:

await prisma.studentClass.updateMany({ data: {}, where: { classId: 1 } });

Expected behavior

When mutation input has no fields, the whole operation should be not available as it makes no sense.

It should be removed from DMMF so other prisma ecosystem tools don’t suffer from this issue.

Prisma information

model Student {
  id           Int            @id @default(autoincrement())
  name         String
  StudentClass StudentClass[]
}

model Class {
  id           Int            @id @default(autoincrement())
  name         String
  StudentClass StudentClass[]
}

model StudentClass {
  studentId Int
  classId   Int
  student   Student @relation(fields: [studentId], references: [id])
  class     Class   @relation(fields: [classId], references: [id])

  @@id([studentId, classId])
}

Environment & setup

  • OS: Windows 10 x64 @ WSL2 Ubuntu 20.04
  • Database: PostgreSQL
  • Node.js version: 14.13
  • Prisma version:
@prisma/cli          : 2.9.0
@prisma/client       : 2.9.0
Current platform     : debian-openssl-1.1.x
Query Engine         : query-engine 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/query-engine-debian-openssl-1.1.x)
Migration Engine     : migration-engine-cli 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/introspection-engine-debian-openssl-1.1.x)
Format Binary        : prisma-fmt 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/prisma-fmt-debian-openssl-1.1.x)
Studio               : 0.296.0
Preview Features     : connectOrCreate, atomicNumberOperations

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:21
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
MichalLytekcommented, Dec 8, 2021

Bump! It’s been a half-year since the last comment 😛 It’s a pretty urgent issue I believe, and the workarounds are hard to achieve. 😞

6reactions
matthewmuellercommented, Mar 12, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Empty join table for ManyToMany Relationship - Stack Overflow
I want to see whether you are setting WaterQuality objects in case study or CaseStudy objects in WaterQuality. If You will be adding ......
Read more >
The right way to use a ManyToManyField in Django
To maintain a many-to-many relationship between two tables in a database, the only way is to have a third table which has references...
Read more >
Creating forms from models - Django documentation
The generated Form class will have a form field for every model field specified, in the order specified ... ManyToManyField is represented by...
Read more >
Relate and Unrelate functions in Power Apps - Microsoft Learn
For many-to-many relationships, the system that links the records maintains a hidden join table. You can't access this join table directly; it ...
Read more >
Hibernate Many-to-Many Association with Extra Columns in ...
We are going to introduce two different solutions to cope with the additional fields of the join table in the above relationship diagram....
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