Skip to content

Commit bb624e0

Browse files
committed
rm extra comp
1 parent 1c26f64 commit bb624e0

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

sql/types/json.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,18 @@ func (t JsonType) Compare(ctx context.Context, a interface{}, b interface{}) (in
4747

4848
func convertJSONValue(v interface{}) (interface{}, sql.ConvertInRange, error) {
4949
var data []byte
50-
50+
var charsetMaxLength int64 = 1
5151
switch x := v.(type) {
5252
case []byte:
5353
data = x
5454
case string:
55-
charsetMaxLength := sql.Collation_Default.CharacterSet().MaxLength()
56-
length := int64(len(x)) * charsetMaxLength
57-
if length > MaxJsonFieldByteLength {
58-
return nil, sql.InRange, ErrLengthTooLarge.New(length, MaxJsonFieldByteLength)
59-
}
6055
data = []byte(x)
56+
charsetMaxLength = sql.Collation_Default.CharacterSet().MaxLength()
6157
default:
6258
return nil, sql.OutOfRange, sql.ErrInvalidJson.New("unsupported JSON input type")
6359
}
6460

65-
if int64(len(data)) > MaxJsonFieldByteLength {
61+
if int64(len(data))*charsetMaxLength > MaxJsonFieldByteLength {
6662
return nil, sql.InRange, ErrLengthTooLarge.New(len(data), MaxJsonFieldByteLength)
6763
}
6864

0 commit comments

Comments
 (0)