Skip to content

Conversation

@elianddb
Copy link
Contributor

@elianddb elianddb commented Jul 8, 2025

Fixes dolthub/dolt#9424

  • Allow enum types to reference each other in foreign keys regardless of string values
  • MySQL allows enum foreign keys to match based on underlying numeric values
  • Modified foreignKeyComparableTypes to handle enum types specially
  • Updated test expectations to use correct error types (ErrForeignKeyChildViolation)

🤖 Generated with Claude Code

elianddb and others added 8 commits July 8, 2025 16:11
- Allow enum types to reference each other in foreign keys regardless of string values
- MySQL allows enum foreign keys to match based on underlying numeric values
- Modified foreignKeyComparableTypes to handle enum types specially
- Updated test expectations to use correct error types (ErrForeignKeyChildViolation)
- Removed Skip flag from 'enums with foreign keys' test

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Convert ErrConvertingToEnum to ErrDataTruncatedForColumn in INSERT context
- This matches MySQL behavior for enum validation errors
- Fixed the 'value X is not valid for this Enum' vs 'Data truncated for column' issue

Note: Still debugging foreign key constraint validation issue
- Fixed enum validation error messages in INSERT context
- Core enum FK creation functionality works correctly
- Some test cases still failing due to constraint validation issues
- Need to debug why enum FK constraints aren't being enforced properly
- Update test expectations from 'value X is not valid for this Enum' to 'Data truncated for column'
- Ensures consistency with MySQL 8.0 error message format
- Fixes enum_errors and enums_with_default test failures
- Update test to expect ErrDataTruncatedForColumn instead of ErrConvertingToEnum
- Removes TODO comment as the fix is now implemented
- Matches MySQL behavior for enum validation error messages
- Added ErrDataTruncatedForColumnAtRow error type in types/enum.go
- Added rowNumber field to insertIter struct to track current row
- Modified enum error conversion in insert.go to use row-specific error
- Updated test expectations in script_queries.go to match new format
- MySQL returns: 'Data truncated for column 'e' at row 1'
- Now matches MySQL behavior exactly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Updated issue 8611 test to expect ErrDataTruncatedForColumnAtRow instead of ErrDataTruncatedForColumn
- Test was failing because it expected the old error type without row information
- All INSERT IGNORE tests now pass with the new MySQL-compliant error format

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
elianddb added a commit that referenced this pull request Jul 8, 2025
- Add ErrDataTruncatedForColumnAtRow error type
- Convert ErrConvertingToEnum to proper error with row number
- Track row numbers in insert iterator for accurate error reporting
- Update test expectations to use new error format
- INSERT IGNORE functionality now works correctly for enum conversion

Based on successful solution from issue 9424 PR #3074
@elianddb elianddb requested a review from jycor July 8, 2025 19:22
Copy link
Contributor

@jycor jycor left a comment

Choose a reason for hiding this comment

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

LGTM!

@elianddb elianddb merged commit c5c4097 into main Jul 8, 2025
8 checks passed
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.

Foreign Keys with enum columns

3 participants