Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL upsert(): Internal error: Attempted to serialize empty result. #17982

Closed
bastianparedes opened this issue Feb 18, 2023 · 3 comments
Closed
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: Attempted to serialize empty result. topic: mysql topic: referentialIntegrity/relationMode topic: upsert()
Milestone

Comments

@bastianparedes
Copy link

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

Versions

Name Version
Node v19.5.0
OS darwin-arm64
Prisma Client 4.10.1
Query Engine aead147aa326ccb985dcfed5b065b4fdabd44b19
Database mysql

Logs

prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine library starting
prisma:client:libraryEngine library started

Client Snippet

const result = await prisma.campaign.upsert({
      create: {
        idStatus: campaign.idStatus,
        name: campaign.name
      },
      update: {
        idStatus: campaign.idStatus,
        name: campaign.name
      },
      where: {
        idCampaign: campaign.idCampaign
      }
    });

Schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider     = "mysql"
  url          = env("DATABASE_URL")
  relationMode = "prisma"
}

model campaign {
  idCampaign Int         @id @default(autoincrement())
  name        String      @default("") @db.VarChar(45)
  idStatus   Int         @default(0)
  status      status      @relation(fields: [idStatus], references: [idStatus], onDelete: NoAction, onUpdate: NoAction, map: "status_ibfk_1")
  evaluator   evaluator[]
  variation   variation[]

  @@index([idStatus], map: "status_ibfk_1")
}

model status {
  idStatus Int        @id @unique(map: "idStatus_UNIQUE")
  value     String     @unique(map: "value_UNIQUE") @db.VarChar(45)
  campaign  campaign[]
}

model evaluator {
  idEvaluator Int
  idCampaign  Int
  name         String   @default("") @db.VarChar(45)
  javascript   String   @default("") @db.VarChar(5000)
  campaign     campaign @relation(fields: [idCampaign], references: [idCampaign], onDelete: NoAction, onUpdate: NoAction, map: "evaluator_ibfk_1")

  @@id([idEvaluator, idCampaign])
  @@index([idCampaign], map: "evaluator_ibfk_1")
}

model variation {
  idVariation Int
  idCampaign  Int
  name         String   @default("") @db.VarChar(45)
  html         String   @default("") @db.VarChar(5000)
  css          String   @default("") @db.VarChar(5000)
  javascript   String   @default("") @db.VarChar(5000)
  traffic      Int      @default(0)
  campaign     campaign @relation(fields: [idCampaign], references: [idCampaign], onDelete: NoAction, onUpdate: NoAction, map: "variation_ibfk_1")

  @@id([idVariation, idCampaign])
  @@index([idCampaign], map: "variation_ibfk_1")
}

Prisma Engine Query

{"X":{}}

Also I want to add: the problem only happens when I want to update in this upsert.

@bastianparedes
Copy link
Author

When I want to upsert, it works the create part, when it panics when update.

@janpio janpio added team/client Issue for team Client. bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: upsert nested upsert labels Mar 2, 2023
@janpio janpio changed the title Internal error: Attempted to serialize empty result. MySQL upsert(): Internal error: Attempted to serialize empty result. Feb 1, 2024
@laplab
Copy link
Contributor

laplab commented Apr 12, 2024

Thank you for reporting the issue, @bastianparedes! We are currently testing the fix for this problem. Would it be possible for you to check your code against this version of Prisma?

npm i prisma@5.13.0-dev.30
npm i @prisma/client@5.13.0-dev.30

Bear in mind that this is a development version and should not be used in production. This is only to check if the issue is fixed.

@laplab
Copy link
Contributor

laplab commented Apr 23, 2024

This issue was fixed in Prisma 5.13.0.

@laplab laplab closed this as completed Apr 23, 2024
@janpio janpio modified the milestones: 5.14.0, 5.13.0 Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: Attempted to serialize empty result. topic: mysql topic: referentialIntegrity/relationMode topic: upsert()
Projects
None yet
Development

No branches or pull requests

3 participants