diff --git a/kernel/av/table.go b/kernel/av/table.go index 69b161efe..50f47e4d6 100644 --- a/kernel/av/table.go +++ b/kernel/av/table.go @@ -591,19 +591,31 @@ func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool if nil != value.Relation && nil != other.Relation { switch operator { case FilterOperatorContains: - if "" == strings.TrimSpace(other.Relation.Content) { - return true + contains := false + for _, c := range value.Relation.Contents { + for _, c1 := range other.Relation.Contents { + if c == c1 { + contains = true + break + } + } } - return strings.Contains(value.Relation.Content, other.Relation.Content) + return contains case FilterOperatorDoesNotContain: - if "" == strings.TrimSpace(other.Relation.Content) { - return true + contains := false + for _, c := range value.Relation.Contents { + for _, c2 := range other.Relation.Contents { + if c == c2 { + contains = true + break + } + } } - return !strings.Contains(value.Relation.Content, other.Relation.Content) + return !contains case FilterOperatorIsEmpty: - return "" == strings.TrimSpace(value.Relation.Content) + return 0 == len(value.Relation.Contents) || 1 == len(value.Relation.Contents) && "" == value.Relation.Contents[0] case FilterOperatorIsNotEmpty: - return "" != strings.TrimSpace(value.Relation.Content) + return 0 != len(value.Relation.Contents) && !(1 == len(value.Relation.Contents) && "" == value.Relation.Contents[0]) } } diff --git a/kernel/av/value.go b/kernel/av/value.go index d3f0cac44..73015cbda 100644 --- a/kernel/av/value.go +++ b/kernel/av/value.go @@ -142,10 +142,14 @@ func (value *Value) String() string { } return "" case KeyTypeRelation: - if nil == value.Relation { + if 1 > len(value.Relation.Contents) { return "" } - return value.Relation.Content + var ret []string + for _, v := range value.Relation.Contents { + ret = append(ret, v) + } + return strings.Join(ret, " ") case KeyTypeRollup: if nil == value.Rollup { return "" @@ -463,7 +467,7 @@ type ValueCheckbox struct { } type ValueRelation struct { - Content string `json:"content"` + Contents []string `json:"contents"` BlockIDs []string `json:"blockIDs"` }