PrismaP
Prisma6mo ago
7 replies
Jvwooo-er 👻

Prisma views (for MongoDB) with composite types causes Engine Panic

Hi,

It seems that Composite types are not supported anymore(?) in prisma views with MongoDB

I was upgrading my codebase from Prisma version from 5.19.0 to 6.13.0, I used the upgrade guide on the website.
When trying out my application I discovered that views with a composite type (any non string, date, int etc. but type {...}) throws an Engine Panic.
Commenting out those fields in the schema results in a working engine again.

I have 2 views in my app
Flat view:
view ZohoUser {
  id              String    @map("_id") @db.ObjectId
  zohoId          String
  sub             String?
  email           String
  emailVerified   DateTime?
  isEmailVerified Boolean   @default(false)
  name            String
  firstName       String?
  lastName        String?
  createdAt       DateTime @default(now())
  updatedAt       DateTime @updatedAt

  @@map("zoho-users")
}


Non working view (with types):
view DealPhoto {
  id          String           @map("_id") @db.ObjectId
  blobName    String
  dealId      String
  createdById String?
  createdAt   DateTime
  updatedAt   DateTime
  revision    Int
  config      PhotoConfig
  drawing     DealPhotoDrawing
  rank        Int?
  source      PhotoSource?

  @@map("deal-photos")
}

enum PhotoSource {
  PARTNER
  MANUAL
  ZOHO
}

type DealPhotoDrawing {
  version String
  objects Json[]
}

type PhotoConfig {
  labels PhotoLabel[] @default([])
  note   String       @default("")
}

enum PhotoLabel {
  LABEL_ONE
  ...
}


Using the old prisma version this worked perfectly however after migrating to the newest version I get an Engine Panic:
thread 'tokio-runtime-worker' panicked at query-engine/query-structure/src/field/scalar.rs:96:17:
internal error: entered unreachable code: This shouldn't be reached; composite types are not supported in compound unique indices.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
PrismaClientRustPanicError: 
Invalid `prisma.dealPhoto.findMany()` invocation:


internal error: entered unreachable code: This shouldn't be reached; composite types are not supported in compound unique indices.

This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.


I could not find any reference to this change in the upgrade migration guide. I'm wondering if I'm overlooking something or if this is now not supported anymore in views?
Was this page helpful?