rails icon indicating copy to clipboard operation
rails copied to clipboard

Map enums using array to the correct column type

Open lazaronixon opened this issue 3 months ago • 0 comments

Motivation / Background

Previously enums without keywords were always mapped to integers and indexed by position, now it is converted based on the column type, it works for strings and database enums as well.

# Before
enum status: { proposed: "proposed", written: "written", published: "published" }

# After
enum status: [:proposed, :written, :published]

Detail

This Pull Request closes #47278

Checklist

Before submitting the PR make sure the following are checked:

  • [x] This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • [x] Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • [x] Tests are added or updated if you fix a bug or add a feature.
  • [x] CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

lazaronixon avatar Feb 19 '24 08:02 lazaronixon