Skip to content

Commit 2fbe509

Browse files
committed
add docstrings
1 parent 5e4478f commit 2fbe509

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sql/expression/convert.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,18 +474,20 @@ func createConvertedDecimalType(length, scale int, logErrors bool) sql.DecimalTy
474474
return types.InternalDecimalType
475475
}
476476

477+
// prepareForNumberContext makes necessary preparations to strings and byte arrays for conversions to numbers
477478
func prepareForNumericContext(val interface{}, originType sql.Type, isInt bool) (interface{}, error) {
478479
if s, isString := val.(string); isString && types.IsTextOnly(originType) {
479480
return trimStringToNumberPrefix(s, isInt), nil
480481
}
481482
return convertHexBlobToDecimalForNumericContext(val, originType)
482483
}
483484

485+
// trimStringToNumberPrefix trims a string to the appropriate number prefix
484486
func trimStringToNumberPrefix(s string, isInt bool) string {
485487
if isInt {
486-
s = strings.Trim(s, types.IntCutSet)
488+
s = strings.TrimLeft(s, types.IntCutSet)
487489
} else {
488-
s = strings.Trim(s, types.NumericCutSet)
490+
s = strings.TrimLeft(s, types.NumericCutSet)
489491
}
490492

491493
seenDigit := false

0 commit comments

Comments
 (0)