RobinBlomberg / kysely-codegen

Generate Kysely type definitions from your database.
MIT License
773 stars 69 forks source link

Make Postgres adapter set column types as JS number for Numeric PG type #134

Closed pharmajoe990 closed 7 months ago

pharmajoe990 commented 7 months ago

See this issue, have encountered the same behaviour. I'm not sure if this is intended behaviour or a bug, but I am using Postgres and my Select queries are incompatible with the generated schema for NUMERIC Postgres types. I can't see any reason to generate these types as below (maybe I'm missing something though):

export type Numeric = ColumnType<string, number | string, number | number>

I thought it should generate

export type Numeric = ColumnType<number, number | number, number | number>

I would assume that SELECTs, INSERTs and UPDATEs should all expect a Javascript number type to be the input/output type.

Many thanks for building out the project, it's proven really useful 🙂

pharmajoe990 commented 7 months ago

On further reading, it seems the pg driver returns all numerics as strings by default. Implementation makes more sense now. Closing this one, many thanks 🙂