-
Notifications
You must be signed in to change notification settings - Fork 19
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 field stored as value instead of integer causing invalid enum error #59
Comments
This is an application specific issue. Im not sure that theres anything that should be done within this library to prevent that. You should probably adopt an enum deprecation plan similar to postgres where you can never remove an enum value from the list. Its possible that someone could create a PR compiling a list of possible data-maintenance pitfalls if that seems useful. |
Thank you for the clarification. While I understand the suggestion regarding enum deprecation, I still feel that storing the enum's database value (the integer) rather than the Rails representation (the string) could help mitigate issues like this in the future. By using the database value in snapshots, we would avoid problems arising from changing enum strings over time. I understand that this gem is not necessarily Rails-specific, so it may not make sense to implement something that only caters to Rails enums. However, it would be great to have an option or mechanism that allows for storing the database value (like an integer) rather than the framework-specific value (like a string in Rails). This could provide a more generic and robust solution for users across different frameworks. |
Ok ya I'd be open to something that solves this. Feel free to create a PR |
The fix for this has been merged |
v0.5.0 is now released which contains this fix. |
Currently, the enum field is being stored as its string value rather than the corresponding integer. As a result, when the enum value is changed, an error occurs:
"old_enum_value is not a valid enum_field" when calling fetch_reified_items on a snapshot.
This seems to be happening due to the enum's value changing over time, causing previously stored values to become invalid.
Example:
enum role: [admin customer]
changed toenum role: [staff customer]
Error message:
admin
is not a validrole
The text was updated successfully, but these errors were encountered: