Jared Fraser
07/13/2022, 6:00 AMstring
in the DB but have constraints placed on the field at the DB level to restrict the values to a set (just like an enum).
In previous versions of Prisma, we defined these in our schema as an enum
and all was well, it worked perfectly.
However in trying to upgrade to Prisma 4, we've started to get the error
meta: {
code: 'XXUUU',
message: 'db error: ERROR: cannot create enum of unspecified type'
},
Which I'm assuming is that Prisma no longer knows how to cast the string db value to the enum defined in the schema.
Any tips for how to progress? Any way to define a string value in prisma with a set of possible string values?janpio
Jared Fraser
07/14/2022, 4:02 AMenums
and not the string issue I thought it was.
Previous Prisma version: 3.14.0
Database connector: CockroachDB
That error message is being thrown when we run a raw query where we are adding a where
clause with an enum
I have built a reproducible repo https://github.com/jared-fraser/prisma-enum
I've included 2 package files to allow you to swap from 3.14 to 4, to show that it worked in 3.14 and not in 4.
Problem line: https://github.com/jared-fraser/prisma-enum/blob/master/script.ts#L20Jared Fraser
07/14/2022, 4:16 AMAND te.source = ${SourceEnum.testA}::source_enum
then the query works againjanpio
Jared Fraser
07/14/2022, 11:45 AM