Skip to content

Conversation

@theAnuragMishra
Copy link
Contributor

and leaving the rest in their original case.

closes #4202

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🔧 golang labels Dec 1, 2025
Comment on lines +38 to +40
if len(p) > 0 {
out += strings.ToUpper(p[:1]) + p[1:]
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't any whitespace in p (see line 31 above), so this code will do the same thing as strings.Title.

Copy link

@em-ily-dev em-ily-dev Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, actually, slicing off the first byte would split up a multi-byte character, and fail to convert it. The existing call to strings.Title will properly uppercase a multi-byte character.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it have to do with the existence of whitespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree on the problem with multibyte characters though.
We can split the string in runes and convert the first rune in that case? Not sure how uppercasing works with multibyte chars, gotta find out.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strings.Title already does what we want here. #4202 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files. 🔧 golang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve upper-case when mapping SQL identifiers to Go identifiers

2 participants