Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singular Flag Does Not Affect Enum or Column Names #223

Open
omtodkar opened this issue Dec 10, 2024 · 0 comments
Open

Singular Flag Does Not Affect Enum or Column Names #223

omtodkar opened this issue Dec 10, 2024 · 0 comments

Comments

@omtodkar
Copy link

omtodkar commented Dec 10, 2024

I am using Kysely's code generation tool for a PostgreSQL database. The database contains an enum type for statuses, and I am trying to generate TypeScript types using the --singular flag.

However, when I use the --singular flag, the tool correctly generates table names in singular form (e.g., user instead of users). Unfortunately, it does not generate enum or column names in singular form. These remain in their plural form (e.g., statuses instead of status).

Actual sample ts file:

export type Statuses = "ACTIVE" | "INACTIVE";

export interface User {
  // ... other fields.
  Statuses: Generated<Statuses>;
  userId: Generated<string>;
}

Steps to Reproduce:

  1. Have a PostgreSQL database with an enum type (e.g., statuses).
  2. Use enum type in a table with similar singular name (e.g. status).
CREATE TYPE statuses AS ENUM ('ACTIVE', 'INACTIVE');

CREATE TABLE IF NOT EXISTS users (
    user_id bigserial PRIMARY KEY,
    name text,
    status statuses DEFAULT 'ACTIVE' NOT NULL
);
  1. Run the kysely-codegen command with the --singular flag:
npx kysely-codegen --singular --dialect=postgres --url="<DATABASE_URL>" --out-file="./types.ts"
  1. Observe that:
  • Table names are generated in singular form.
  • enum and column names still remain in plural form.

Expected Behavior:

The --singular flag should apply to all generated types, including enum and column names, ensuring consistency in the naming convention across the generated code.

Actual Behavior:

Only the table names are converted to singular form, while enum and column names remain in plural form.

Kysely Versions:

kysely: 0.27.4
kysely-codegen: 0.17.0

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant