studio icon indicating copy to clipboard operation
studio copied to clipboard

BigInt issue?

Open LB22 opened this issue 2 years ago • 2 comments

  1. Prisma version (prisma -v or npx prisma -v):
prisma                  : 3.10.0
@prisma/client          : 3.10.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\query_engine-windows.dll.node)       
Migration Engine        : migration-engine-cli 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\migration-engine-windows.exe)   
Introspection Engine    : introspection-core 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\introspection-engine-windows.exe) 
Format Binary           : prisma-fmt 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash    : 73e60b76d394f8d37d8ebd1f8918c79029f0db86
Studio                  : 0.458.0
  1. Logs from Developer Tools Console or Command line, if any:
TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at new er (http://localhost:5555/assets/index.js:1:162650)
    at bs (http://localhost:5555/assets/vendor.js:27:50128)
    at Ha (http://localhost:5555/assets/vendor.js:27:67591)
    at bl (http://localhost:5555/assets/vendor.js:27:105796)
    at gu (http://localhost:5555/assets/vendor.js:27:97229)
    at hu (http://localhost:5555/assets/vendor.js:27:97154)
    at iu (http://localhost:5555/assets/vendor.js:27:94183)
    at http://localhost:5555/assets/vendor.js:27:45779
    at e.unstable_runWithPriority (http://localhost:5555/assets/vendor.js:18:3854)
  1. Does the issue persist even after updating to the latest prisma CLI dev version? (npm i -D prisma@dev) Got this warning: Versions of [email protected] and @prisma/[email protected] don't match. Tried to run prisma studio anyways, the issue persisted.

  2. Prisma schema (if relevant):

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

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model customer {
  id                  BigInt    @id @unique @default(autoincrement())
  created_at          DateTime? @default(now()) @db.Timestamptz(6)
  first_name          String?   @db.VarChar
  last_name           String?   @db.VarChar
  email_address       String?   @db.VarChar
  mobile_phone_number String?   @db.VarChar
  orders              order[]
}

model order {
  id                       BigInt    @id @unique @default(autoincrement())
  created_at               DateTime? @default(now()) @db.Timestamptz(6)
  stripe_payment_intent_id String?   @unique @db.VarChar
  products                 Json[]    @db.Json
  customer                 customer? @relation(fields: [customerId], references: [id])
  customerId               BigInt
}

So, I created 2 customers and 1 order. At first I set customer 1 as owner of the order. Then I switched the order to have the second customer as owner of the order. Then I tried clicking on any of the "order" buttons under the customer table and then prisma studio gave me the type error.

I tried changing the id types from BigInt to Int and re-did the whole operation. Now it works fine.

Is there some issue with BigInt?

Just saw that this is a duplicate and this issue has been posted here too: https://github.com/prisma/studio/issues/816#issuecomment-1010143567

Should this be closed?

LB22 avatar Mar 15 '22 09:03 LB22