Skip to content

knexSnakeCaseMappers for camelCase1 #1025

@dwoowb

Description

@dwoowb

Hi,

Just want to say I appreciate your efforts on this library and I have enjoyed using it thus far!

I have a use case for conversion for a variable like camelCase1 to write to my DB as camel_case_1, however, I'm noticing that the current implementation of snakeCase converts said variable from camelCase1 to camel_case1.

I tried out the lodash implementation of snakeCase which gives me the desired result. Another option that would elicit the desired effect for me would be changing the conditional here from:

if (char === upperChar && upperChar !== lowerChar) { ... }

to:

if (char === upperChar) { ... }

But of course I am not entirely sure of the use cases you have run into and are trying to support on your end.

I tried playing around with configuring knexSnakeCaseMappers but realized that knexIdentifierMappers (which is where I would pass in my own choice of camel/snakeCase functions) is not being exported.

Please let me know what you think, I'd be more than happy to discuss and open a PR based on our conversation!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions