Skip to content

Conversation

@nicktobey
Copy link
Contributor

When altering the possible values of an enum column, the mapping between enum strings and their indexes may change. In order to alter the column correctly, we need to map the old indexes onto the new ones.

This PR fixes two bugs in that mapping process:

  • Previously, we were converting the row to the new schema before setting the enums to their new index. This means that if the old row had an index that didn't exist in the new schema, this conversion would fail. By setting the enums to their new index before we convert the row to the new schema, we avoid this problem.
  • Enum indexes are 1-indexed, with the 0 value representing an "invalid" value. One way to get an invalid enum in MySQL is an INSERT IGNORE statement where the provided value for the enum is out of range. Dolt also allows setting the column to 0 directly, although MySQL does not. Previously, we were not able to alter enum columns if they contained a 0 value, but now we can.

Copy link
Contributor

@macneale4 macneale4 left a comment

Choose a reason for hiding this comment

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

LGTM

@nicktobey nicktobey merged commit c5f7d51 into main May 6, 2025
8 checks passed
@nicktobey nicktobey deleted the nicktobey/enum branch May 6, 2025 00:33
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.

3 participants