-
Notifications
You must be signed in to change notification settings - Fork 33
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
Enum IDs Can't Be Strings #21
Comments
Yes, it is a limitation of the plugin. I use a type check to decide if the argument to in the [] is an id and you want to return a name, or a name and you want the id. I've been thinking of moving away from the [] accessor and going with Enum.id(name) and Enum.name(id). Only issue name is defined on Module. But I can override and check for an argument and pass to super if there is no argument. |
the type is used to determine what you want from the [] accessor. We can't accept string ids without breaking the current behaviour. |
@adzap I know, we talked about it. I say for protocol :) Maybe you will think about new version's behavior... |
Perhaps we should explore this more. What is the use case for a string ID? Do you actually use this example in code? Is the enum being used to enumerate attributes on the model? |
Looking at the code referenced in this issue, it doesn't seem possible to create an enum where the id is a string.
You can see this in an example:
will result in:
Lookup by name works as expected:
The text was updated successfully, but these errors were encountered: