make dep and fix words releated->related

This commit is contained in:
wanyaoqi
2018-08-28 13:39:54 +08:00
parent 51dffdadb1
commit 1e5a231e06
4 changed files with 26 additions and 8 deletions
Generated
+2 -2
View File
@@ -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"
+1 -1
View File
@@ -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)
+19 -1
View File
@@ -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
}
+4 -4
View File
@@ -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
}