prisma icon indicating copy to clipboard operation
prisma copied to clipboard

Support Composite Types for PostgreSQL

Open imkiva opened this issue 2 years ago • 11 comments

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.

imkiva avatar Jan 25 '24 08:01 imkiva

Would be a nice addition!

bobbonius avatar Mar 22 '24 09:03 bobbonius

+1

Module32 avatar Jun 20 '24 15:06 Module32

Any updates on this yet?

beardedhorseman avatar Jul 30 '24 00:07 beardedhorseman

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

zacBkh avatar Aug 08 '24 13:08 zacBkh

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.

axxo1337 avatar Aug 30 '24 18:08 axxo1337

I really hope they add support for it at some point 😊

axxo1337 avatar Aug 30 '24 18:08 axxo1337

+1

ZanzyTHEbar avatar Sep 22 '24 18:09 ZanzyTHEbar

Any updated on this?

linhtrinh18 avatar Sep 23 '24 03:09 linhtrinh18

+1 would be perfect!

Fiser12 avatar Sep 23 '24 12:09 Fiser12

+1

micro927 avatar Oct 06 '24 09:10 micro927

+1

wibawaarif avatar Oct 17 '24 08:10 wibawaarif

+1 This would make things a whole lot better when working with JSON.

redicides avatar Oct 21 '24 14:10 redicides

+1

fmoessle avatar Nov 04 '24 13:11 fmoessle

Any news on this? It is becoming more and more necessary and useful.

hugocruzlfc avatar Nov 13 '24 17:11 hugocruzlfc

Same here. I reverted back to using MongoDB just to have support for them again.

redicides avatar Nov 13 '24 19:11 redicides

Typesafe is key nowaday development, hope it will support this feature soon.

linhtrinh18 avatar Nov 14 '24 03:11 linhtrinh18

Composite types are actually supported since Postgres 13 and yes, it would be nice to see them added to prisma support! :)

SonnyAD avatar Nov 20 '24 07:11 SonnyAD

JSON or a new model just for a type is really annoying, would be nice if this got official support in prisma

Prabhuomkar9 avatar Nov 22 '24 06:11 Prabhuomkar9

Any updates?

a-suenami avatar Dec 07 '24 01:12 a-suenami

+1

martynassimkevicius avatar Dec 17 '24 15:12 martynassimkevicius

+1

webstyle avatar Dec 18 '24 07:12 webstyle

+1

bek-shoyatbek avatar Jan 15 '25 16:01 bek-shoyatbek

+1

Intbar avatar Jan 19 '25 05:01 Intbar

+1

zhangpanrobot avatar Jan 25 '25 10:01 zhangpanrobot

+1

inkloop avatar Feb 08 '25 22:02 inkloop

This would be great addition to Postgres connecto!

jorgeramirezamora avatar Feb 14 '25 18:02 jorgeramirezamora

+1

SimonDucak avatar Feb 20 '25 08:02 SimonDucak

Any updates on this?

beardedhorseman avatar Feb 20 '25 09:02 beardedhorseman

+1

Abhishek332 avatar Feb 27 '25 18:02 Abhishek332

+1

pradyutsingh avatar Apr 12 '25 18:04 pradyutsingh