Git Product home page Git Product logo

Comments (8)

iiian avatar iiian commented on July 20, 2024 1

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.

iiian avatar iiian commented on July 20, 2024

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.

iiian avatar iiian commented on July 20, 2024

@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.

iiian avatar iiian commented on July 20, 2024

@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.

antonioorct avatar antonioorct commented on July 20, 2024

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.

antonioorct avatar antonioorct commented on July 20, 2024

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.

iiian avatar iiian commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.