JasonShin / sqlx-ts

node.js compile-time SQL validations & type generations
https://jasonshin.github.io/sqlx-ts/
MIT License
179 stars 6 forks source link

Generate enum types from Postgres and MySQL #188

Closed JasonShin closed 3 weeks ago

JasonShin commented 4 weeks ago

Context So far sqlx-ts wasn't able to generate enum types from DB - instead it has generated an any type. With this PR, sqlx-ts will be able to generate enum types, but it will generate all possible enum values as an union of strings

e.g.


export type UsersQueryParams = [];

export interface IUsersQueryResult {
    enum1: 'x-small' | 'small' | 'medium' | 'large' | 'x-large';
};

export interface IUsersQueryQuery {
    params: UsersQueryParams;
    result: IUsersQueryResult;
};