Skip to content

Commit f6751b7

Browse files
elianddbclaude
andcommitted
Inline validateForeignKeyDecimalScales function
- 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]>
1 parent e137c6b commit f6751b7

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

sql/plan/foreign_key_editor.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -549,18 +549,13 @@ func (reference *ForeignKeyReferenceHandler) shouldRejectDecimalMatch(ctx *sql.C
549549
return false
550550
}
551551
indexColumnTypes := reference.RowMapper.Index.ColumnExpressionTypes()
552-
return validateForeignKeyDecimalScales(reference.ForeignKey, reference.RowMapper.SourceSch, reference.RowMapper.IndexPositions, indexColumnTypes)
553-
}
554-
555-
// validateForeignKeyDecimalScales checks if any DECIMAL columns have different scales between child and parent
556-
func validateForeignKeyDecimalScales(fk sql.ForeignKeyConstraint, childSch sql.Schema, indexPositions []int, parentTypes []sql.ColumnExpressionType) bool {
557-
for i := range fk.Columns {
558-
if i >= len(parentTypes) {
552+
for i := range reference.ForeignKey.Columns {
553+
if i >= len(indexColumnTypes) {
559554
continue
560555
}
561-
childColIdx := indexPositions[i]
562-
childDecimal, childOk := childSch[childColIdx].Type.(sql.DecimalType)
563-
parentDecimal, parentOk := parentTypes[i].Type.(sql.DecimalType)
556+
childColIdx := reference.RowMapper.IndexPositions[i]
557+
childDecimal, childOk := reference.RowMapper.SourceSch[childColIdx].Type.(sql.DecimalType)
558+
parentDecimal, parentOk := indexColumnTypes[i].Type.(sql.DecimalType)
564559
if childOk && parentOk && childDecimal.Scale() != parentDecimal.Scale() {
565560
return true
566561
}

0 commit comments

Comments
 (0)