RobinBlomberg / kysely-codegen

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

Adding an overrides property that allows for column types to be overridden #147

Closed gittgott closed 5 months ago

gittgott commented 5 months ago

This is somewhat related to #34, #75, and #30.

This follows the format in the JSON configuration issue (#34), so it should be adaptable to that. This does not implement any sort of TypeScript parsing. It will simply copy the value of the column name's override as an IdentifierNode. This will at least allow for simple type overrides, but I'm not entirely certain of what will and won't be supported with this.

I was also uncertain if the override in #transformColumn should truly override the type or if it should respect the isNullable or isGenerated parts of that. For now, I just have it as a true override which ignores those.

I have kept this as a property on the Generator class, and it is not included as a CLI option. I was not sure how this would be best implemented, so I left it alone for now and am just making it available through custom scripts.

I'm looking for some feedback on my prior uncertainties and if I'm missing anything glaringly obvious. Thanks!