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

Enums are not mapped #34

Closed
alizeegtd opened this issue Aug 28, 2023 · 5 comments
Closed

Enums are not mapped #34

alizeegtd opened this issue Aug 28, 2023 · 5 comments

Comments

@alizeegtd
Copy link

My enums defined in PascalCase are not mapped when running prisma-case-format --map-field-case snake --map-table-case snake

@iiian
Copy link
Owner

iiian commented Aug 28, 2023

My enums defined in PascalCase are not mapped when running prisma-case-format --map-field-case snake --map-table-case snake

Hi @alizeegtd! Would you be willing to give a minimal example input and point out what your expected vs actual diff is?

@alizeegtd
Copy link
Author

Hi @iiian, my initial Prisma schema looks like:

enum UserLocale {
  fr_FR
  en_EN
}

model User {
  id          Int        @id @default(autoincrement())
  email       String     @unique
  firstName   String     @default("")
  lastName    String     @default("")
  locale      UserLocale @default(fr_FR)
}

When I run the following command: prisma-case-format --map-field-case snake --map-table-case snake, my Prisma schema gets modified to become:

enum UserLocale {
  fr_FR
  en_EN
}

model User {
  id          Int        @id @default(autoincrement())
  email       String     @unique
  firstName   String     @default("") @map("first_name")
  lastName    String     @default("") @map("last_name")
  locale      UserLocale @default(fr_FR) @map("locale")

  @@map("user")
}

I was expecting to get:

enum UserLocale {
  fr_FR
  en_EN

 @@map("user_locale")
}

model User {
  id          Int        @id @default(autoincrement())
  email       String     @unique
  firstName   String     @default("") @map("first_name")
  lastName    String     @default("") @map("last_name")
  locale      UserLocale @default(fr_FR) @map("locale")

  @@map("user")
}

@iiian
Copy link
Owner

iiian commented Aug 31, 2023

version 1.7.3 pushed, please pull and retry

@alizeegtd
Copy link
Author

@iiian Thanks it works now. I'm just surprised that when using the param --map-table-case snake,plural it pluralize the enum name (e.g. UserLocale -> @@map("user_locales")) but that's fine.

@iiian
Copy link
Owner

iiian commented Aug 31, 2023

@iiian Thanks it works now. I'm just surprised that when using the param --map-table-case snake,plural it pluralize the enum name (e.g. UserLocale -> @@map("user_locales")) but that's fine.

Well, drop thr plural?

@iiian iiian closed this as completed Aug 31, 2023
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

2 participants