-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feature request: Support @map and @@map for mapping column and table names #40
Comments
@tinacious Thank you for your feedback! It definitely makes sense to support this, I'll carve out some time to work on this feature, I'll let you know whenever it is released It is worth mentioning though that the attributes |
@emyann thanks for the response and your openness to supporting this feature. I see the part of the documentation you are pointing to, and I can see how it may sound confusing. Right below the part you indicated, there's further explanation. Here is a sample schema that is probably more appropriate given that it's resource-oriented that you can try using if you haven't tried to use the mappings yourself: model Puppy {
id Int @id @default(autoincrement())
isCute Boolean @default(true) @map("is_cute")
@@map("puppies")
} This creates a table Perhaps the part in the docs that you indicate says it does not rename the table is in the event the table has already been created. When the table is created initially, I assure you the name I indicate in With the sample puppies schema, As per the docs, if omitted, the table and column names are created verbatim, resulting in a PascalCase table and camelCase columns: So far all my tables have been single words, I have not tested what the client looks like for models that contain multiple words, i.e. I'm not sure how it translates the PascalCase model and what the result would be in the generated client if it would be Now, if you mentioned that part of the docs because your plugin uses the Prisma client to infer the names rather than the database columns directly or the schema file (which would have both, I assume), that is understandable, but I assure you the columns and tables are named as indicated by the mappings. It would be great to be able to configure a choice, e.g.:
In an organization that uses micro-services and may have these micro-services written in different languages (with different naming conventions, e.g. a mix of Ruby and JavaScript services), if it can be expected that they all follow the naming conventions of their databases, it would be great if the UML diagrams that were generated could optionally match these too. Let me know if you need anymore information. Thanks again for this plugin. |
I understand better thanks! I've never tried myself |
First off, amazing library, thank you!
Prisma allows you to map column names, for example, if you wanted to stick to JavaScript naming conventions (as camelCase) in the code, and database naming conventions in the database (as snake_case), it adds
@map("my_column_name")
.It also has a
@@map("table_name")
for the table name should you not want to use the default PascalCase naming convention in the database.For example, here is an example schema:
The Plant UML that gets generated uses the field
isAwesome
but it would be great if it could use the database fieldis_awesome
, either by default or as a configuration option.Thanks again for this great tool! Very quick and easy to get going with.
The text was updated successfully, but these errors were encountered: