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

Fix nested attribute name and generated custom value method name conflicts #81

Merged
merged 8 commits into from
Nov 14, 2023

Conversation

bendbennett
Copy link
Contributor

@bendbennett bendbennett commented Oct 26, 2023

Closes: #76

Refer to issue comment for details regarding the changes in this PR.

…e when the attribute name matches any of the generated custom value method names (#76)
@bflad
Copy link
Contributor

bflad commented Oct 26, 2023

For additional context: I do not believe we can we get away with unexported (lowercase first letter) field names which would wholly eliminate this problem since the framework's reflection needs them to be exported.

So given that, I don't think we have much choice in this situation -- we need to munge the field names in some fashion. Another option could be to potentially suffix (these or all) field names with "Attribute"/"Field" or similar. Not sure if that's any better or worse than prefixing in terms of developers trying to find field names that are now mismatched with the attribute names.

Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

LGTM, one nit :shipit:

// Example:
// - equal(something) -> somethingEqual
// - type(something) -> somethingType
func (identifier FrameworkIdentifier) ToPrefixCamelCase(name string) string {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Would changing the name of the input parameter to prefix make more sense in this context? Same for the method below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point. Have updated.

@bendbennett bendbennett merged commit 0b1c795 into main Nov 14, 2023
3 checks passed
@bendbennett bendbennett deleted the bendbennett/issues-76-#2 branch November 14, 2023 16:56
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failure in code generation if nested attribute defines name with reserved Go keyword
3 participants