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.

PANIC: Expected record selection to contain required model ID fields.: ConversionFailure("\"c266149d-e045-4db5-bee4-3e49f3252e65\"", "Int") in query-engine/core/src/interpreter/interpreter.rs:68:26

See original GitHub issue

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

Versions

Name Version
Node v16.13.0
OS darwin-arm64
Prisma Client 3.8.1
Query Engine 0.1.0
Database mysql

Logs

prisma:tryLoadEnv Environment variables loaded from /Users/edmbn/Projects/remix/proc-app/.env
prisma:tryLoadEnv Environment variables loaded from /Users/edmbn/Projects/remix/proc-app/.env
prisma:client clientVersion: 3.8.1
prisma:client clientEngineType: library
prisma:client:libraryEngine internalSetup
prisma:client:libraryEngine Searching for Query Engine Library in /Users/edmbn/Projects/remix/proc-app/node_modules/.prisma/client
prisma:client:libraryEngine loadEngine using /Users/edmbn/Projects/remix/proc-app/node_modules/.prisma/client/libquery_engine-darwin-arm64.dylib.node
prisma:client:libraryEngine library starting
prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine library already starting, this.libraryStarted: false
prisma:client:libraryEngine library started
prisma:client:libraryEngine sending request, this.libraryStarted: true

Client Snippet

  const organization = await db.organization.update({
    where: { id: organizationId },
    data: {
      name: organizationInformation.name,
    },
  });

Schema

model Organization {
  id                      Int                      @id @default(autoincrement())
  name                    String
  processes               Process[]
}

model Process {
  id             String               @id @default(uuid()) @db.VarChar(36)
  description    String?              @db.LongText
  organizationId Int
  organization   Organization         @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)

  @@index([organizationId])
}

Generated SQL

CREATE TABLE `Organization` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `Process` (
  `id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` longtext COLLATE utf8mb4_unicode_ci,
  `organizationId` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `Process_organizationId_idx` (`organizationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Used database

Planetscale

The error happens when updating any field of the Organization model.

I’m using referentialIntegrity preview feature with option referentialIntegrity = "prisma" Same error happens with prisma studio.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
justinwaitecommented, Feb 26, 2022

Also have the issue. I had a user model with an autoincrement id (Int), and a reset token model with a cuid as the ID (String). Changing the reset token id to an Int and using a separate field for the the actual token string fixed the problem for me.

Seems like referential integrity does not like mixing ID data types across entities.

2reactions
Ju99ernautcommented, Mar 31, 2022

Seems like referential integrity does not like mixing ID data types across entities.

I can confirm this too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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