-
Notifications
You must be signed in to change notification settings - Fork 642
Description
First off, thanks so much for your work on Objection. It's really a great piece of work.
The issue I'm running into is that the current knexSnakeCaseMappers implementation converts strings like isALevel to is_alevel, isBLevel to is_blevel, etc. This means that if you have a column like is_a_level or is_b_level, you can't access it when using knexSnakeCaseMappers (as far as I can tell, at least). isBLevel and isBlevel both get mapped to the same thing: is_blevel.
It looks like the code adds a special case for when there are two or more consecutive uppercase letters here:
objection.js/lib/utils/identifierMapping.js
Lines 55 to 61 in 5b76a4c
| // Multiple consecutive upper case characters shouldn't add underscores. | |
| // For example "fooBAR" should be converted to "foo_bar". | |
| if (prevChar === prevUpperChar && prevUpperChar !== prevLowerChar) { | |
| out += lowerChar; | |
| } else { | |
| out += '_' + lowerChar; | |
| } |
Would it make sense to add a parameter to disable this special case, similar to how you handled underscoreBeforeDigits?
| function snakeCase(str, { upperCase = false, underscoreBeforeDigits = false } = {}) { |