valtyr/prisma-kysely

[feature] support `Unsupported()` types

Opened this issue · 4 comments

cayter commented

schema.prisma

generator kysely {
  provider           = "prisma-kysely"
  output             = "../../build/prisma/primary"
  fileName           = "types.ts"
  unsupportedFilename = "unsupported-types.ts"
}

model Payment {
  id     BigInt                              @id @default(autoincrement())
  amount Unsupported("money_with_currency")?
}

types.ts (generated by prisma-kysely)

import UnsupportedTypes from '~/unsupported-types';

export type Payment = {
    id: Generated<bigint>;
   amount: UnsupportedTypes['money_with_currency'] | null;
}

unsupported-types.ts (defined by us manually)

export type MoneyWithCurrency = {
  amount: bigint;
  currency: CurrencyCode;
}

export const Unsupported = {
  'money_with_currency': MoneyWithCurrency
} as const;

Would this be possible? We're currently stuck with this and realised that Prisma wouldn't support custom type just for Postgres use case. Would be great if we can make this happen. Thanks.

dylel commented

hey @valtyr, any idea how we can deal with unsupported types? I've looked into it a bit but the Prisma Generator Helper doesn't seem to parse in any columns that are "Unsupported" meaning they aren't in the DMMF. Can we read them ourselves somehow?

I have a Unsupported("geometry") that I want to map to a string as thats what the kysely driver uses.

janpio commented

Prisma side feature request to put Unsupported into DMMF so it is available for generators: prisma/prisma#20756

dylel commented

thanks @janpio for linking that, this is my issue I opened last week. I'm looking for an alternative in the meantime to deal with this as it could be sometime before this is added to the DMMF

janpio commented

(Your username did seem familiar 😆)