Skip to content

Case

SQLQueryEncoder.KeyEncodingStrategy.convertToSnakeCase

Convert from camelCaseKeys to snake_case_keys before writing a key to a row.
case convertToSnakeCase

Discussion

Capital characters are determined by testing Character.isUppercase.

Converting from camel case to snake case:

  1. Splits words at the boundary of lower-case to upper-case.

  2. Inserts _ between words.

  3. Lowercases the entire string.

  4. Preserves starting and ending _.

For example, oneTwoThree becomes one_two_three. _oneTwoThree_ becomes _one_two_three_.

Note

Using a key encoding strategy has a nominal performance cost, as each string key has to be converted.