Skip to content

Conversation

@kyleconroy
Copy link
Collaborator

Append _ to variable names that are reserved

Fixes #2267

Append `_` to variable names that are reserved
@andrewmbenton
Copy link
Collaborator

Honestly I don't think I would even bother checking for reserved words, since that list is something we'll have to keep up to date. I would just append or prepend "_" to every variable name since they are all internal to sqlc's funcs anyway.

@kyleconroy
Copy link
Collaborator Author

kyleconroy commented Oct 13, 2023

The list of reserved words in Go is very short and changes infrequently. I don't think they've added one for years. I'd rather not generated a large diff for existing users.

@kyleconroy kyleconroy merged commit 3ae9e3c into main Oct 13, 2023
@kyleconroy kyleconroy deleted the kyle/codegen-go-keywords branch October 13, 2023 18:36
alfonsodev pushed a commit to ExponentiaTeam/sqlc that referenced this pull request Oct 13, 2025
* fix(golang): Escape reserved keywords

Append `_` to variable names that are reserved
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.

Generated code uses Go keyword resulting in a syntax error

3 participants