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

Store enum value as integer #60

Merged

Conversation

akmalcm
Copy link
Contributor

@akmalcm akmalcm commented Sep 27, 2024

Fixed issue #59

attributes = instance.attributes
attributes.each do |k, v|
if instance.class.defined_enums.key?(k)
attributes[k] = instance.class.defined_enums[k][v]
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
attributes[k] = instance.class.defined_enums[k][v]
attributes[k] = instance.class.defined_enums.fetch(k).fetch(v)

assert_equal @snapshot.id, snapshot_item.snapshot_id

assert_equal @snapshot.snapshot_items.first.object['status'], snapshot_item.object['status']
Copy link
Owner

@westonganger westonganger Oct 1, 2024

Choose a reason for hiding this comment

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

Can we put these assertions in their own well defined test case instead of using the existing generic test case.

@akmalcm akmalcm force-pushed the fix/enum-to-store-as-integer branch from 90ed624 to b0f75b9 Compare October 1, 2024 06:26
@westonganger westonganger changed the title Fix enum to store as integer Store enum value as integer Nov 7, 2024
@westonganger westonganger merged commit 25c25cb into westonganger:master Nov 7, 2024
21 checks passed
@westonganger
Copy link
Owner

westonganger commented Nov 7, 2024

Upgrade steps once this update is released:

Old records will still suffer from this bug, will need a manual data update to resolve this. New records will be stored correctly going forward.

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.

2 participants