pyramation / inflection

inflection is a port of the functionality from Ruby on Rails' Active Support Inflection classes into PostgreSQL
MIT License
5 stars 2 forks source link

Odd behaviour with uppercase characters #1

Open brendanmckenzie opened 3 years ago

brendanmckenzie commented 3 years ago

I'm experiencing some odd behaviour when changing case on terms such as GraphQL where uppercase characters make part of a word. See below for examples.

# select inflection.underscore( 'GraphQL hello world' );
      underscore      
----------------------
 graphq_l_hello_world

# select inflection.underscore( 'GraphQL WebACL hello world' );
         underscore          
-----------------------------
 graphql_weba_cl_hello_world
pyramation commented 3 years ago

hi! I actually do need to revisit the consecutive caps. What do you believe the correct result is in these cases?

Let me know what you think makes sense. The attempt was to not have consecutive caps and attempt to sort out the groupings.

I imagine maybe this makes sense?

GraphQL WebACL hello world => graph_ql_web_acl_hello_world

it's a bit tricky, because I wanted to try and make sure things are isomorphic when going between underscore, camelcase, supercase, etc, etc. For example, GraphqlProject => graphql_project => GraphqlProject. I always found when combining caps into names, like GraphQL it adds complexity to object names. Happy to do whatever the best practice is.

pyramation commented 3 years ago

here is an example in JS for reference https://codesandbox.io/s/inspiring-sun-rn6jm?file=/src/App.js https://gist.github.com/pyramation/1e3e29091284a52bf0b10a966939e04b

brendanmckenzie commented 3 years ago

Ideally, it would be graphql_webacl_hello_world but I understand how that adds more complexity.