Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(codegen): Preserve casing of names by uppercasing the first character... #4210

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

Open
theAnuragMishra wants to merge 1 commit into sqlc-dev:main
base: main
Choose a base branch
Loading
from theAnuragMishra:main

Conversation

@theAnuragMishra
Copy link
Contributor

@theAnuragMishra theAnuragMishra commented Dec 1, 2025

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:]
}
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.

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
edited
Loading

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

@theAnuragMishra theAnuragMishra Dec 4, 2025

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

@theAnuragMishra theAnuragMishra Dec 4, 2025

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.

Copy link

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

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

Reviewers

1 more reviewer

@em-ily-dev em-ily-dev em-ily-dev left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Preserve upper-case when mapping SQL identifiers to Go identifiers

AltStyle によって変換されたページ (->オリジナル) /