carp icon indicating copy to clipboard operation
carp copied to clipboard

Rust enum information lost when generating Typescript

Open SebastienGllmt opened this issue 3 years ago • 4 comments

When defining our database schema, we made enums (such as the block era) be represented at the database level by plain ints. The problem with this is that later on when we use Prisma to generate the Typescript type definition, it means they end up being represented in Typescript as just plain number which is not typesafe and also hurts readability.

I'm not sure if Prisma supports SQL enums, but it's something to investigate

SebastienGllmt avatar Apr 10 '22 20:04 SebastienGllmt

just commenting because I've used Prisma before, it does seem like Prisma supports enums depending on which db image https://www.prisma.io/docs/reference/database-reference/database-features#misc

Mercurial avatar Apr 11 '22 03:04 Mercurial

Probably we won't be using Prisma since in the end I don't think it supports the features we need.

SebastienGllmt avatar Apr 11 '22 11:04 SebastienGllmt

@SebastienGllmt I'm curious to what features you're saying don't exist in Prisma and what alternative client you would use that does cover those features?

CyberCyclone avatar Apr 24 '22 04:04 CyberCyclone

@CyberCyclone I want typed raw SQL, not an ORM. This is provided by pgtyped

SebastienGllmt avatar Apr 24 '22 05:04 SebastienGllmt