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

Prepend an underscore to a StructName if it starts with a digit. #1554

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

avalonbits
Copy link
Contributor

@avalonbits avalonbits commented Apr 16, 2022

This situation can occur if the column name starts with an underscore prefix and the following character is a digit:

create table thing (
 _1099Form text
);

currently the generator would balk because the generated struct would be :

type Thing struct {
  1099Form string
}

and 1099Form is not a valid name (it starts with a digit).

with this change we would instead get instead:

type Thing struct {
  _1099Form string
}

Copy link
Collaborator

@kyleconroy kyleconroy left a comment

Choose a reason for hiding this comment

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

Thanks for the code! If the tests pass, I'll merge (and add a test too)

@kyleconroy kyleconroy merged commit 52b6bb4 into sqlc-dev:main Apr 22, 2022
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

Successfully merging this pull request may close these issues.

2 participants