field-name-mapping-snake-case rule not working for field with custom types or enums
Closed this issue · 5 comments
When the field is a custom type in MongoDB or the field is a enum in for example Postgres the rule field-name-mapping-snake-case do not thrown any warning / error.
Example for enum (Postgres):
model Sale {
id Int @id @default(autoincrement())
saleChannel SaleChannel
@@map("sale")
}
enum SaleChannel {
TERMINAL
WEB
MOBILE
}
In the example above, the field saleChannel
should be mapped to @map("sale_channel")
when the field-name-mapping-snake-case it's on, but the lint do not throws a warning or an error.
Example for custom types (MongoDB):
model Location {
id String @id @default(uuid()) @map("_id")
additionalInformation LocationAdditionalInformation
@@map("location")
}
type LocationAdditionalInformation {
institution String?
printExtraBarCode Boolean? @map("print_extra_bar_code")
taxMessage String? @map("tax_message")
}
In the example above, the field LocationAdditionalInformation
should be mapped to @map("additional_information")
when the field-name-mapping-snake-case it's on, but the lint do not throws a warning or an error.
Interesting. We don't use DB enums so haven't run into this. I'll try to take a look this weekend.
We need to update this function:
prisma-lint/src/rules/field-name-mapping-snake-case.ts
Lines 135 to 143 in 4da8cb6