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.

Expected parent IDs to be set when ordering by parent ID.

See original GitHub issue

Hi Prisma Team! My Prisma Client just crashed. This is the report:

Versions

Name Version
Node v16.16.0
OS debian-openssl-1.1.x
Prisma Client 4.3.1
Query Engine c875e43600dfe042452e0b868f7a48b817b9640b
Database mysql

The logs in this case were a useless red herring. There were some of our queryRaw included, but not the problem which was “Invalid prisma.letting.findMany() invocation:Expected parent IDs to be set when ordering by parent ID. This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.”

I can work on a minimal replication, but this is what we have so far.

Client Snippet

    const lettings = await this.context.prisma.agency(agencyid).letting.findMany({
      include: {
        lettingSchedules: {
          where: { iswithdrawn: false },
        },
      },
      orderBy: [
        { lettingid: 'asc' },
      ],
    })

Client Snippet 2 minimal

await prisma.letting.create({
  data: {
    lettingid: 'UPPERCASE',
  }
})

await prisma.lettingSchedule.create({
  data: {
    lettingid: 'uppercase',
    contid: 'some-contid',
  }
})

const lettings = await prisma.letting.findMany({
  include: { lettingSchedules: true },
})

Schema

model Letting {
  lettingid     String    @id @db.VarChar(45)
  lettingdate   DateTime? @db.Timestamp(0)
  lettingSchedules LettingSchedule[]

  @@map("letting")
}

model LettingSchedule {
  lettingid        String    @db.VarChar(45)
  contid           String    @db.VarChar(45)
  callorder        String?   @db.VarChar(45)
  iswithdrawn      Boolean?
  letting Letting @relation(fields: [lettingid], references: [lettingid])

  @@id([lettingid, contid])
  @@map("lettingschedule")
}

I’ve cut out some extra where clauses and edited the schema for brevity. Prisma failed to recognize the link between the tables when lettingid was “29apr11” in letting and “29APR11” in lettingschedule. I had to log in to the production database and change production data to get the cases to match to stop the error.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Druuecommented, Oct 25, 2022

Yep! I’ve taken a look and have confirmed your teammate’s reproduction @sdkuck

1reaction
sdkuckcommented, Oct 25, 2022

Yes, this still happens with 4.5.0 We are using MySQL 5.7 ~You didn’t include the prisma.findMany query you used, but in trying to replicate this locally we found that the problem goes away if you have a where: {...} clause. Just do the findMany with an include and nothing else.~ Sorry, just saw the repo for the reproduction. I’ll take a look at that and see if we can make it break. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

MySQL: PANIC: Expected parent IDs to be set when ordering ...
Hi Prisma Team! My Prisma Client just crashed. This is the report: Versions Name Version Node v12.22.7 OS debian-openssl-1.1.x Prisma Client 3.1.1 Query ......
Read more >
Prisma Client API (Reference)
AssertionError("Expected a valid parent ID to be present for nested update to-one case.") If the related record that you want to update does...
Read more >
Parent ID query | Elasticsearch Guide [8.5] | Elastic
(Required, string) ID of the parent document. The query will return child documents of this parent document.
Read more >
how to get all children by multiple parent ids using IN() clause
I'm trying to get all children records by their parent IDs(multiple) using IN clause but its return only children belong to first parent...
Read more >
Parent IDs in API - Wrike Help Center
Has there been any discussion about creating a field where we can set what the authoritative or home folder ID? I know this...
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