From 1e5a231e0686acf0006ba330bae1bc38da95d3ff Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Tue, 28 Aug 2018 13:39:54 +0800 Subject: [PATCH] make dep and fix words releated->related --- Gopkg.lock | 4 ++-- pkg/cloudcommon/db/db_dispatcher.go | 2 +- vendor/yunion.io/x/pkg/gotypes/gotypes.go | 20 ++++++++++++++++++- .../x/pkg/util/filterclause/filterclause.go | 8 ++++---- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index dd0d306013..99299205d0 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1053,7 +1053,7 @@ [[projects]] branch = "master" - digest = "1:8e2a4d71738e5e3bffc415b23f100b0a5033dbf88154783122f5147d4fc213b5" + digest = "1:8a2992edca980cb03eb9dc89f62c03c8ab6fe0c5ca4fc1da71eb736aae635f65" name = "yunion.io/x/pkg" packages = [ "gotypes", @@ -1088,7 +1088,7 @@ "utils", ] pruneopts = "UT" - revision = "7348c84865abac3fcdec618591b7eee7c2e0669b" + revision = "1e97a2736e5b90c0274b7d391b8d97aa9107725c" [[projects]] branch = "master" diff --git a/pkg/cloudcommon/db/db_dispatcher.go b/pkg/cloudcommon/db/db_dispatcher.go index 57b6ea13c9..6c8c336a87 100644 --- a/pkg/cloudcommon/db/db_dispatcher.go +++ b/pkg/cloudcommon/db/db_dispatcher.go @@ -259,7 +259,7 @@ func applyListItemsGeneralJointFilters(manager IModelManager, q *sqlchemy.SQuery jointModelManager := GetModelManager(jfc.GetJointModelName()) schFields := searchFields(jointModelManager, userCred) if ok, _ := utils.InStringArray(jfc.GetField(), schFields); ok { - sq := jointModelManager.Query(jfc.ReleatedKey) + sq := jointModelManager.Query(jfc.RelatedKey) cond := jfc.GetJointFilter(sq) if cond != nil { sq = sq.Filter(cond) diff --git a/vendor/yunion.io/x/pkg/gotypes/gotypes.go b/vendor/yunion.io/x/pkg/gotypes/gotypes.go index e589aa7c61..615499fa4a 100644 --- a/vendor/yunion.io/x/pkg/gotypes/gotypes.go +++ b/vendor/yunion.io/x/pkg/gotypes/gotypes.go @@ -120,6 +120,15 @@ func ParseValue(val string, tp reflect.Type) (reflect.Value, error) { } case reflect.String: return reflect.ValueOf(val), nil + case reflect.Ptr: + tpElem := tp.Elem() + rv, err := ParseValue(val, tpElem) + if err != nil { + return reflect.ValueOf(val), fmt.Errorf("Cannot parse %s to %s", val, tp) + } + rvv := reflect.New(tpElem) + rvv.Elem().Set(rv) + return rvv, nil default: if tp == TimeType { tm, e := timeutils.ParseTimeStr(val) @@ -173,7 +182,16 @@ func SetValue(value reflect.Value, valStr string) error { Float32SliceType, Float64SliceType, StringSliceType: reflect.Append(value, reflect.ValueOf(valStr)) default: - return fmt.Errorf("Unsupported type: %v", value.Type()) + if value.Kind() == reflect.Ptr && value.Elem().Kind() != reflect.Slice { + newVal := reflect.New(value.Type().Elem()) + newValElem := newVal.Elem() + if err := SetValue(newValElem, valStr); err != nil { + return err + } + value.Set(newVal) + } else { + return fmt.Errorf("Unsupported type: %v", value.Type()) + } } return nil } diff --git a/vendor/yunion.io/x/pkg/util/filterclause/filterclause.go b/vendor/yunion.io/x/pkg/util/filterclause/filterclause.go index 5518ea0f3b..a0928f6527 100644 --- a/vendor/yunion.io/x/pkg/util/filterclause/filterclause.go +++ b/vendor/yunion.io/x/pkg/util/filterclause/filterclause.go @@ -18,8 +18,8 @@ type SFilterClause struct { type SJointFilterClause struct { SFilterClause - JointModel string - ReleatedKey string + JointModel string + RelatedKey string } func (jfc *SJointFilterClause) GetJointFilter(q *sqlchemy.SQuery) sqlchemy.ICondition { @@ -108,8 +108,8 @@ func ParseJointFilterClause(jointFilter string) *SJointFilterClause { funcName: matches[4], params: params, }, - JointModel: matches[1], - ReleatedKey: matches[2], + JointModel: matches[1], + RelatedKey: matches[2], } return &jfc }