RobinBlomberg / kysely-codegen

Generate Kysely type definitions from your database.
MIT License
815 stars 73 forks source link

How to handle decimals properly? #185

Closed tzezar closed 3 months ago

tzezar commented 3 months ago

We are using postgres database, it returns decimals as number, but kysely-codegen make those strings. This makes super hard to work with zod schema validation because typing schema properly (value as string) raise schema does not match results and typing it correctly raise ts error at response level.

Upvote & Fund

Fund with Polar

tzezar commented 3 months ago

Parsing types was not working untill we reinstalled every dependency - no idea why this happend. Because there is no way in kysely-codegen to specify to which types values are generated I believe this is only way simplifying things.

const numericTypeId = 1700;
pg.types.setTypeParser(numericTypeId, (val: string) => {
  return String(val);
});