P
Prisma•4w ago
Jvwer

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")
}
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
...
}
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.
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?
4 Replies
Prisma AI Help
Prisma AI Help•4w ago
You selected the bot's instantaneous insights. Let me compile your answer right away! You're correct that there has been a change in Prisma's support for composite types (custom types defined with type {...}) in certain contexts, especially with MongoDB and views. Based on the error message you provided and the recent issues reported, Prisma's engine now explicitly panics when composite types are used in compound unique indices or as part of certain schema constructs that are not supported. This is a recent validation added to prevent undefined or unstable behavior, and it appears to affect views as well as models. The error message you see:
internal error: entered unreachable code: This shouldn't be reached; composite types are not supported in compound unique indices.
matches exactly with recent issues where composite types are used in places Prisma does not support, such as in IDs or unique constraints for MongoDB models or views. This validation was introduced around Prisma v5.4.0 and later, and is now enforced in the query engine, causing a panic if violated. The relevant discussion and confirmation of this change can be found in this issue and this comment. Unfortunately, the official Prisma documentation and upgrade guides do not yet explicitly mention this breaking change for views, but the engine behavior is now clear: composite types are not supported in views (or models) where they are part of a unique index, ID, or similar constraint. This is enforced to prevent engine panics and undefined behavior. Workaround:
You will need to remove or comment out composite type fields from your view definitions to avoid this error, as you discovered. There is currently no supported way to use composite types in Prisma views for MongoDB in the latest versions. If this is a critical use case for you, consider following or commenting on the related GitHub issues for updates and possible future support. [Source: GitHub Issue #25955](<htt ps://github.com/prisma/prisma/issues/25955>) 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Nurul
Nurul•4w ago
Hey, we made some view related changes in version 6.13.0, could you see if you get the same issues in 6.12.0 as well? https://github.com/prisma/prisma/releases/tag/6.13.0
GitHub
Release 6.13.0 · prisma/prisma
Today, we are excited to share the 6.13.0 stable release 🎉 🌟 Star this repo for notifications about new releases, bug fixes &amp; features — or follow us on X! Highlights In this ORM release, we’re...
Jvwer
JvwerOP•3w ago
Hi Nurul, thank you for your reply. It seems that you're right. 6.13 has changes related to views that breaks our implementation. For now I'll switch to 6.12, which seems to work perfectly fine! Do you know if there is any plan to expand views with composite types again? Or should we make changes to our model?
Nurul
Nurul•7d ago
Did you get a chance to look at release 6.14.0? https://github.com/prisma/prisma/releases/ Some of the use cases should now be possible again with 6.14 release
GitHub
Releases · prisma/prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB - prisma/prisma

Did you find this page helpful?