Skip to content

Commit b6cf2ec

Browse files
Potential fix for code scanning alert no. 397: Incorrect conversion between integer types
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 4a2ac39 commit b6cf2ec

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

sql/yeartype.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ func (t yearType) Convert(v interface{}) (interface{}, error) {
116116
if value < float64(math.MinInt16) || value > float64(math.MaxInt16) {
117117
return nil, ErrConvertingToYear.New("float64 value out of bounds for int16")
118118
}
119+
// Check for fractional part
120+
if value != float64(int16(value)) {
121+
return nil, ErrConvertingToYear.New("float64 value has a fractional component, cannot convert to int16")
122+
}
119123
return int16(value), nil
120124
case decimal.Decimal:
121125
return t.Convert(value.IntPart())

0 commit comments

Comments
 (0)