Support Composite Types for PostgreSQL
Problem
Currently the composite types are only supported for MongoDB. Given the type
type ProductBillingCycle {
month Int
discountRatio Float
}
and an error is raised:
Error: P1012
error: Error validating: Composite types are not supported on Postgres.
--> schema.prisma:215
|
214 |
215 | type ProductBillingCycle {
216 | month Int
217 | discountRatio Float
218 | }
|
Suggested solution
PostgreSQL has added support for composite type in version 16, as from the document.
It would be nice if Prisma could support this feature.
Alternatives
I am using a String for the purpose, and do manually JSON conversion to perform CRUD on that type,
which is error-prone and not type-safe.
Would be a nice addition!
+1
Any updates on this yet?
Definitely would be a game changer! If I am not mistaken, at the moment there is no way in Prisma to embed an object right? We need to create a new model and reference it
Definitely would be a game changer! If I am not mistaken, at the moment there is no way in Prisma to embed an object right? We need to create a new model and reference it
Yeah you can't use composite types unless you're using mongo db. Your only close alternative is storing JSON or XML objects but that's disgusting to be honest. Until it is possibly implemented you have to rely on foreign keys and extra tables.
I really hope they add support for it at some point 😊
+1
Any updated on this?
+1 would be perfect!
+1
+1
+1 This would make things a whole lot better when working with JSON.
+1
Any news on this? It is becoming more and more necessary and useful.
Same here. I reverted back to using MongoDB just to have support for them again.
Typesafe is key nowaday development, hope it will support this feature soon.
Composite types are actually supported since Postgres 13 and yes, it would be nice to see them added to prisma support! :)
JSON or a new model just for a type is really annoying, would be nice if this got official support in prisma
Any updates?
+1
+1
+1
+1
+1
+1
This would be great addition to Postgres connecto!
+1
Any updates on this?
+1
+1