RobinBlomberg / kysely-codegen

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

Postgres DATE type #194

Open m3Lith opened 1 month ago

m3Lith commented 1 month ago

The Date type in Postgres (haven't checked other dialects) is used for date-only data, like 'YYYY-MM-DD', etc (see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-INPUT-DATES). In the generator here, it's using a Timestamp definition. IMO, a string would be more correct. What do you think?

So far, I've used a type parser (pg.types.setTypeParser(pg.types.builtins.DATE, (val) => val.toString())) to get the selected value as a string by default, otherwise it returns JS Date object, and I need to explicitly select it using sql<string>${ref('date')}::text``.

Upvote & Fund

Fund with Polar