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:
Non working view (with types):
Using the old prisma version this worked perfectly however after migrating to the newest version I get an Engine 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
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:
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.
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.
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 & features — or follow us on X!
Highlights
In this ORM release, we’re...
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?
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