P
Prisma2mo ago
Undo

Many-to-many relation started silently failing to perform joins

Hi Prisma team! My jaw has dropped to the floor. I've a critical problem with the ORM. Many-to-many relations are not joining. As you can see in the code snippet below the query fetches a row and joins the "rawRequirements". There are 311 relations. The count is correct. The join is not working. No I can't reproduce this issue in a fresh repo. I assume this problem is caused by upgrading prisma?
const requirements = await prisma.universityProgramRequirement.findUnique(
{
where: { id: "Engelska 6" },
select: {
id: true,
_count: {
select: {
rawRequirements: true,
},
},
rawRequirements: {
select: {
id: true,
},
},
},
},
);
console.log(requirements);
const requirements = await prisma.universityProgramRequirement.findUnique(
{
where: { id: "Engelska 6" },
select: {
id: true,
_count: {
select: {
rawRequirements: true,
},
},
rawRequirements: {
select: {
id: true,
},
},
},
},
);
console.log(requirements);
model UniversityRawRequirements {
id String @id @default(cuid())

programs UniversityProgram[]
rawRequirements String @unique
requirements UniversityProgramRequirement[]
source UniversityRawRequirementsSource
status UniversityRawRequirementsStatus
}

model UniversityProgramRequirement {
id String @id

name String
description String?
rawRequirements UniversityRawRequirements[]

@@index([name])
}
model UniversityRawRequirements {
id String @id @default(cuid())

programs UniversityProgram[]
rawRequirements String @unique
requirements UniversityProgramRequirement[]
source UniversityRawRequirementsSource
status UniversityRawRequirementsStatus
}

model UniversityProgramRequirement {
id String @id

name String
description String?
rawRequirements UniversityRawRequirements[]

@@index([name])
}
No description
7 Replies
Prisma AI Help
Prisma AI Help2mo ago
Salutations, traveler! I'm the Prisma AI Help Bot. You've reached a fork in the road: one path leads to the wisdom of the human sages (ETA: sometime today), and the other to my instantaneous insights. Which way shall we go?
Undo
UndoOP2mo ago
using latest prisma
Marc Hess
Marc Hess2mo ago
Hey @Undo thanks for reporting this. Could you open a github issue so our engineers are made aware?
Undo
UndoOP2mo ago
ok @Marc Hess the problem is I can't create a minimal reproducable example. Worst kinds of bugs I know but this type of issue would never arise with a clean slate since the units tests would have easily caught it. Is it fine to open an issue anyway and just to provide as much relevant information as possible?
Marc Hess
Marc Hess2mo ago
Please do! I think you may have found something rare yes but it may be breaking enough that we need to prioritize it. I am not the one to make that call but at least with a proper issue the people that can have the ability to.
Undo
UndoOP2mo ago
done: https://github.com/prisma/prisma/issues/28346 for those who found this thread and ran into the same issue see the workaround section for how to solve this.
GitHub
Many-to-many relation started silently failing to perform joins · ...
Bug description A many-to-many relation is in place and shows up in "npx prisma studio" but joins are not joining. This is related to an old database with prisma upgraded. Severity ⚠️ Maj...
Undo
UndoOP2mo ago
Although we could fix existing relations unfortunately this caused a lot of damage for us since lots of work silently failed and we were oblivious. Of course it's understood software sometimes fails, I just hope this helps someone else struggling with the same issue.

Did you find this page helpful?