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

11 messages · Page 1 of 1 (latest)

mild tiger
#

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);
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])
}
muted jettyBOT
#

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?

mild tiger
#

using latest prisma

rapid nest
#

Hey @mild tiger thanks for reporting this. Could you open a github issue so our engineers are made aware?

mild tiger
#

@rapid nest 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?

rapid nest
#

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.

mild tiger
#

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.