Comments (8)
Okay, I'll be able to get to this issue by Tuesday next week at the earliest. I think you're probably right that this is broken slash an oversight in needed functionality
from prisma-case-format.
I swear this is possible today, let me look through the code for a moment and get back to you but if it's not possible then yes I agree let's support this
from prisma-case-format.
@antonioorct I have two solutions that you might explore:
1: using !
Model:
field:
columnsSingular: 'mapField=!columns_singular'
The exclamation point tells the mapField
to "use this exact value".
2: using ,singular
Model:
field:
columnsSingular: 'mapField=snake,singular'
This says "use snakecase with a singular plurality convention when trying to map this field"
This works, because case-convention syntax is always:
(snake|pascal|camel)[,(singular|plural)]
Also, a plural=disable
would probably be equivalent to specifying ,singular
from prisma-case-format.
@antonioorct another thing you could do that would help me to help you is to clarify, explicitly, what your desired outcome is: right now, it's still a bit ambiguous and unclear which of the following you want to occur:
columnsSingular String[] @map("columns_singular") // both field & mapField singular
columnsSingulars String[] @map("columns_singular") // mapField singular
columnsSingular String[] @map("columns_singulars") // field singular
from prisma-case-format.
I'm running prisma-case-format --pluralize
because I want to pluralize array fields, but I have a field I want ignored.
I've tried both of your solution and neither of them worked and I've also tried various combinations of field
, mapField
and similar with also explicit naming !
and that also didn't work.
Essentially I want the field
name to be forced to singular
I want the following to be the final output:
columnsSingular String[] @map("columns_singular")
from prisma-case-format.
https://github.com/antonioorct/prisma-case-format-test
I've created a reproducible example in this repository:
npm install
npm run format-prisma
I've set field=camel,singular
but running with --pluralize
ignores that, sets the field to be plural but the mapped field remains singular.
from prisma-case-format.
Hey @antonioorct, please install [email protected]
and give it a test. You should be able to do any of the following columnsSingular
paradigms:
default: 'field=camel; table=pascal; enum=pascal; pluralize=true'
override:
Model:
field:
columnsSingular: 'mapField=snake,singular'
columnsSingular: 'mapField=snake; pluralize=disable'
columnsSingular: 'mapField=!columns_singular' # this will preserve pluralization
Additionally, you can now specify -p
at the command line or embed it in the config file. Up to you.
from prisma-case-format.
Related Issues (20)
- Add --map-field-case / --map-table-case option HOT 5
- "prisma-case-format" command not found HOT 2
- enum definitions do not stay PascalCase when running 'prisma db pull' HOT 8
- Doesn't map after first table HOT 7
- Exclude the next code from fomatting. HOT 3
- TypeError: Cannot read properties of null (reading 'groups') HOT 4
- Pluralize table names HOT 8
- Some `@@index` cannot be converted HOT 4
- `Unsupported` fields are parsed incorrectly HOT 5
- Enums are not mapped HOT 5
- Add a LICENSE file HOT 4
- Ignore Command & Excluding Enums HOT 4
- Any way to keep enums singular when table names are plural? HOT 3
- Broken output for pascal case HOT 4
- New version of package have old content HOT 1
- No @@map created for enums HOT 5
- Possibility to skip some models HOT 23
- Q. How to use this tool ? HOT 8
- Retain @map annotations for fields with distinct DB column names HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma-case-format.