-
-
Notifications
You must be signed in to change notification settings - Fork 230
dolthub/dolt#9496 - Fix DECIMAL foreign key constraint validation to match MySQL behavior #3094
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
Open
elianddb
wants to merge
11
commits into
main
Choose a base branch
from
elianddb/9496-decimal-foreign-keys
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−10
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Allow foreign key references between DECIMAL columns with different precision/scale to match MySQL behavior. - Modified foreignKeyComparableTypes() to allow DECIMAL types with different precision/scale - Updated test expectations to reflect correct behavior with current decimal implementation - All foreign key tests pass Fixes dolthub/dolt#9496 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Added DECIMAL foreign key compatibility test suite to foreign_key_queries.go - Tests foreign key creation between DECIMAL columns with different precision/scale - Tests constraint validation with both valid and invalid inserts - Validates that the fix works for various DECIMAL type combinations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Added logic to detect DECIMAL precision/scale mismatches - DECIMAL types are not ExtendedType so type conversion approach doesn't work - Current implementation partially working but needs refinement - MySQL correctly rejects 78.9 (4,1) -> 78.90 (4,2) FK references - Need to find alternative approach for DECIMAL type comparison 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Allow DECIMAL foreign key creation with different precision/scale - Add strict constraint validation that rejects values with different scales - Use existing sql.DecimalType interface and Index.ColumnExpressionTypes() methods - Ensure 78.9 DECIMAL(4,1) \!= 78.90 DECIMAL(4,2) like MySQL - Clean implementation using existing constructors and functions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Remove verbose comments and dead code - Reduce nesting in shouldRejectDecimalMatch function - Use existing patterns from codebase - Remove unnecessary vitess import - Simplify type checking logic 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Extract foreignKeyHasDifferentDecimalScales as centralized helper - Can be reused by other parts of FK validation logic - Follows existing patterns for FK column iteration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Rename foreignKeyHasDifferentDecimalScales to validateForeignKeyDecimalScales - Follows existing naming pattern in codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Remove unnecessary function separation since it's only used in one place - Keep logic contained within shouldRejectDecimalMatch method - Simplify code structure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Rename shouldRejectDecimalMatch to validateDecimalMatch - Consistent with existing codebase validate naming scheme - Update function call to use new name 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes dolthub/dolt#9496
Allow DECIMAL foreign key creation with different precision/scale but enforce strict constraint validation
MySQL allows DECIMAL foreign keys with different precision/scale but rejects constraint violations based on exact scale matching