RobinBlomberg / kysely-codegen

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

Bug in runtime enums #150

Closed mariandaniel24 closed 1 month ago

mariandaniel24 commented 5 months ago

Hello, in regard to the implementation of runtime enums in #115 , I believe there is a bug with the generated keys. So, given this SQL

CREATE TYPE risk_evaluation_status AS ENUM ('OK', 'CAN_USE', 'SHOULD_NOT_BE_USED');

When I generate types using kysely-codegen --camel-case --runtime-enums --dialect=postgres --out-file=generated/db-types.ts:

The output is:

// It generates this
export enum RiskEvaluationStatus {
    CANUSE = 'CAN_USE',
    OK = 'OK',
    SHOULDNOTBEUSED = 'SHOULD_NOT_BE_USED',
}

// It should actually generate
export enum RiskEvaluationStatus {
    CAN_USE = 'CAN_USE',
    OK = 'OK',
    SHOULD_NOT_BE_USED = 'SHOULD_NOT_BE_USED',
}

Upvote & Fund

Fund with Polar

michael-land commented 5 months ago

Encountering the same issue.

acro5piano commented 3 months ago

Same here. If it's not intended, I'll hopefully create a PR.

RobinBlomberg commented 1 month ago

Should be released in kysely-codegen@0.16.0! 🚀

acro5piano commented 1 month ago

Thanks @RobinBlomberg