vendor: update all dependencies
This commit is contained in:
+32
-11
@@ -60,6 +60,10 @@ func typeMismatchReason(p Property, v reflect.Value) string {
|
||||
return fmt.Sprintf("type mismatch: %s versus %v", entityType, v.Type())
|
||||
}
|
||||
|
||||
func overflowReason(x interface{}, v reflect.Value) string {
|
||||
return fmt.Sprintf("value %v overflows struct field of type %v", x, v.Type())
|
||||
}
|
||||
|
||||
type propertyLoader struct {
|
||||
// m holds the number of times a substruct field like "Foo.Bar.Baz" has
|
||||
// been seen so far. The map is constructed lazily.
|
||||
@@ -243,7 +247,7 @@ func plsFieldLoad(v reflect.Value, p Property, subfields []string) (ok bool, err
|
||||
}
|
||||
|
||||
// setVal sets 'v' to the value of the Property 'p'.
|
||||
func setVal(v reflect.Value, p Property) string {
|
||||
func setVal(v reflect.Value, p Property) (s string) {
|
||||
pValue := p.Value
|
||||
switch v.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
@@ -252,7 +256,7 @@ func setVal(v reflect.Value, p Property) string {
|
||||
return typeMismatchReason(p, v)
|
||||
}
|
||||
if v.OverflowInt(x) {
|
||||
return fmt.Sprintf("value %v overflows struct field of type %v", x, v.Type())
|
||||
return overflowReason(x, v)
|
||||
}
|
||||
v.SetInt(x)
|
||||
case reflect.Bool:
|
||||
@@ -273,12 +277,12 @@ func setVal(v reflect.Value, p Property) string {
|
||||
return typeMismatchReason(p, v)
|
||||
}
|
||||
if v.OverflowFloat(x) {
|
||||
return fmt.Sprintf("value %v overflows struct field of type %v", x, v.Type())
|
||||
return overflowReason(x, v)
|
||||
}
|
||||
v.SetFloat(x)
|
||||
case reflect.Ptr:
|
||||
// v must be either a pointer to a Key or Entity.
|
||||
if v.Type() != typeOfKeyPtr && v.Type().Elem().Kind() != reflect.Struct {
|
||||
// v must be a pointer to either a Key, an Entity, or one of the supported basic types.
|
||||
if v.Type() != typeOfKeyPtr && v.Type().Elem().Kind() != reflect.Struct && !isValidPointerType(v.Type().Elem()) {
|
||||
return typeMismatchReason(p, v)
|
||||
}
|
||||
|
||||
@@ -290,21 +294,38 @@ func setVal(v reflect.Value, p Property) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
switch x := pValue.(type) {
|
||||
case *Key:
|
||||
if x, ok := p.Value.(*Key); ok {
|
||||
if _, ok := v.Interface().(*Key); !ok {
|
||||
return typeMismatchReason(p, v)
|
||||
}
|
||||
v.Set(reflect.ValueOf(x))
|
||||
return ""
|
||||
}
|
||||
if v.IsNil() {
|
||||
v.Set(reflect.New(v.Type().Elem()))
|
||||
}
|
||||
switch x := pValue.(type) {
|
||||
case *Entity:
|
||||
if v.IsNil() {
|
||||
v.Set(reflect.New(v.Type().Elem()))
|
||||
}
|
||||
err := loadEntity(v.Interface(), x)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
case int64:
|
||||
if v.Elem().OverflowInt(x) {
|
||||
return overflowReason(x, v.Elem())
|
||||
}
|
||||
v.Elem().SetInt(x)
|
||||
case float64:
|
||||
if v.Elem().OverflowFloat(x) {
|
||||
return overflowReason(x, v.Elem())
|
||||
}
|
||||
v.Elem().SetFloat(x)
|
||||
case bool:
|
||||
v.Elem().SetBool(x)
|
||||
case string:
|
||||
v.Elem().SetString(x)
|
||||
case GeoPoint, time.Time:
|
||||
v.Elem().Set(reflect.ValueOf(x))
|
||||
default:
|
||||
return typeMismatchReason(p, v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user