Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert_names_case inconsistent with numbers. #1190

Open
mdp-chris opened this issue Jul 29, 2024 · 1 comment
Open

convert_names_case inconsistent with numbers. #1190

mdp-chris opened this issue Jul 29, 2024 · 1 comment

Comments

@mdp-chris
Copy link

if you have a field fooBar19 then setting convert_names_case to True will convert that to foo_bar_19. Awesome
But if the name is foobar19 then it doesn't get converted. Not awesome.

The problem is that both convert_names_in_schema_args and convert_names_in_schema_input only convert if field_name.lower() == field_name is true. So it only does a conversion if there is an uppercase character. But the conversion will add underscores before and after numbers. But if there are no uppercase characters, then names with numbers won't be converted.

I'm not sure what the correct resolution here is. Either skip the uppercase check, and always convert, or check to see if it has uppercase or numbers.

@DamianCzajkowski
Copy link
Contributor

Hi, from what I know, when transforming from camelCase to snake_case, numbers are typically not included in the conversion, at least that's how all the converters I'm familiar with work. However, considering that we already add an underscore before a number in camelCase, I believe we should standardize the solution by always adding an underscore before a number during name conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants