fix: format error should not trigger circuit breaker in sqlx (#3437)

This commit is contained in:
Kevin Wan
2023-07-23 20:40:03 +08:00
committed by GitHub
parent 05db706c62
commit ff04356704
6 changed files with 77 additions and 12 deletions

View File

@@ -158,7 +158,7 @@ func (u *Unmarshaler) fillSlice(fieldType reflect.Type, value reflect.Value, map
refValue := reflect.ValueOf(mapValue)
if refValue.Kind() != reflect.Slice {
return fmt.Errorf("%s: %v", fullName, errTypeMismatch)
return newTypeMismatchErrorWithHint(fullName, reflect.Slice.String(), refValue.Type().String())
}
if refValue.IsNil() {
return nil
@@ -180,9 +180,9 @@ func (u *Unmarshaler) fillSlice(fieldType reflect.Type, value reflect.Value, map
continue
}
valid = true
sliceFullName := fmt.Sprintf("%s[%d]", fullName, i)
valid = true
switch dereffedBaseKind {
case reflect.Struct:
target := reflect.New(dereffedBaseType)
@@ -319,7 +319,6 @@ func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue any,
for _, key := range refValue.MapKeys() {
keythValue := refValue.MapIndex(key)
keythData := keythValue.Interface()
mapFullName := fmt.Sprintf("%s[%s]", fullName, key.String())
switch dereffedElemKind {