Skip to content

Commit 2d9dd1a

Browse files
author
James Cor
committed
todos
1 parent a1b9bef commit 2d9dd1a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

sql/index_builder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func (b *MySQLIndexBuilder) convertKey(ctx *Context, colType Type, keyType Type,
229229
if et, ok := colType.(ExtendedType); ok {
230230
return et.ConvertToType(ctx, keyType.(ExtendedType), key)
231231
} else {
232+
// TODO: would it make more sense for colType.Convert to handle the truncation or just do it here?
232233
key, _, err := colType.Convert(ctx, key)
233234
return key, err
234235
}

sql/types/number.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,21 +1145,24 @@ func convertToUint64(t NumberTypeImpl_, v interface{}) (uint64, sql.ConvertInRan
11451145
case float32:
11461146
if v > float32(math.MaxInt64) {
11471147
return math.MaxUint64, sql.OutOfRange, nil
1148-
} else if v < 0 {
1148+
}
1149+
if v < 0 {
11491150
return uint64(math.MaxUint64 - v), sql.OutOfRange, nil
11501151
}
11511152
return uint64(math.Round(float64(v))), sql.InRange, nil
11521153
case float64:
11531154
if v >= float64(math.MaxUint64) {
11541155
return math.MaxUint64, sql.OutOfRange, nil
1155-
} else if v <= 0 {
1156+
}
1157+
if v <= 0 {
11561158
return uint64(math.MaxUint64 - v), sql.OutOfRange, nil
11571159
}
11581160
return uint64(math.Round(v)), sql.InRange, nil
11591161
case decimal.Decimal:
11601162
if v.GreaterThan(dec_uint64_max) {
11611163
return math.MaxUint64, sql.OutOfRange, nil
1162-
} else if v.LessThan(dec_zero) {
1164+
}
1165+
if v.LessThan(dec_zero) {
11631166
ret, _ := dec_uint64_max.Sub(v).Float64()
11641167
return uint64(math.Round(ret)), sql.OutOfRange, nil
11651168
}

0 commit comments

Comments
 (0)