Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] support Unsupported() types #45

Open
cayter opened this issue May 16, 2023 · 4 comments
Open

[feature] support Unsupported() types #45

cayter opened this issue May 16, 2023 · 4 comments

Comments

@cayter
Copy link

cayter commented May 16, 2023

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.

@cayter cayter changed the title [feature-request] support Unsupported() types [feature] support Unsupported() types May 17, 2023
@dylel
Copy link
Contributor

dylel commented Aug 22, 2023

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
Copy link

janpio commented Aug 22, 2023

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

@dylel
Copy link
Contributor

dylel commented Aug 23, 2023

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
Copy link

janpio commented Aug 23, 2023

(Your username did seem familiar 😆)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants