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

Enable interoperability with ent #50

Closed
mvrahden opened this issue Oct 17, 2021 · 6 comments
Closed

Enable interoperability with ent #50

mvrahden opened this issue Oct 17, 2021 · 6 comments

Comments

@mvrahden
Copy link
Contributor

mvrahden commented Oct 17, 2021

Hi, to improve interoperability with ent and support its enum type-safety, I'd propose to add the Values() []string method (from the EnumValues interface) to the generated enum types, next to String() string.
This feature should likely be opt-in, so it would be beneficial to add a flag for it. I'd propose -values (or -valuesFunc) flag.

I've seen, there is already a generated ***Strings() []string-func, which would just need to be wrapped by the Values() []string method in question.

@dmarkham Would you be open for a PR for this?

An Example:

func (Pill) Values() []string {
  return PillStrings()
}

P.S.: I understand there's a potential for confusion, due to the pre-existing PillValues() []Pill function. But to have typesafety with enums in ent, this proposal is the only way to go from what I see.

@mvrahden
Copy link
Contributor Author

Hi @dmarkham, would be nice to hear your opinion on this. Thanks :)

@dmarkham
Copy link
Owner

dmarkham commented Oct 21, 2021

I think a new flag to add this method would be just fine.

@mvrahden
Copy link
Contributor Author

mvrahden commented Oct 21, 2021 via email

@mvrahden
Copy link
Contributor Author

@dmarkham please have a look at #51 thanks

@mvrahden
Copy link
Contributor Author

@dmarkham Thanks for merging! Would you mind bumping the patch version?

@mvrahden
Copy link
Contributor Author

@dmarkham pls bump version, so that the changes make it into the release. Thanks!

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

No branches or pull requests

2 participants