There was an error while loading. Please reload this page.
1 parent aee2b06 commit 55d0b89Copy full SHA for 55d0b89
tpl/collections/where.go
@@ -53,6 +53,7 @@ func (ns *Namespace) checkCondition(v, mv reflect.Value, op string) (bool, error
53
if !v.IsValid() {
54
vIsNil = true
55
}
56
+
57
mv, mvIsNil := indirect(mv)
58
if !mv.IsValid() {
59
mvIsNil = true
@@ -115,7 +116,7 @@ func (ns *Namespace) checkCondition(v, mv reflect.Value, op string) (bool, error
115
116
return false, nil
117
118
- if v.Kind() != reflect.Interface && mv.Type().Elem().Kind() != reflect.Interface && mv.Type().Elem() != v.Type() {
119
+ if v.Kind() != reflect.Interface && mv.Type().Elem().Kind() != reflect.Interface && mv.Type().Elem() != v.Type() && v.Kind() != reflect.Array && v.Kind() != reflect.Slice {
120
121
122
switch v.Kind() {
@@ -144,6 +145,9 @@ func (ns *Namespace) checkCondition(v, mv reflect.Value, op string) (bool, error
144
145
ima = append(ima, toTimeUnix(mv.Index(i)))
146
147
148
+ case reflect.Array, reflect.Slice:
149
+ slv = v.Interface()
150
+ slmv = mv.Interface()
151
152
153
tpl/collections/where_test.go
@@ -536,6 +536,12 @@ func TestCheckCondition(t *testing.T) {
536
{reflect.ValueOf(true), reflect.ValueOf(false), ">", expect{false, false}},
537
{reflect.ValueOf(123), reflect.ValueOf([]int{}), "in", expect{false, false}},
538
{reflect.ValueOf(123), reflect.ValueOf(123), "op", expect{false, true}},
539
540
+ // Issue #3718
541
+ {reflect.ValueOf([]interface{}{"a"}), reflect.ValueOf([]string{"a", "b"}), "intersect", expect{true, false}},
542
+ {reflect.ValueOf([]string{"a"}), reflect.ValueOf([]interface{}{"a", "b"}), "intersect", expect{true, false}},
543
+ {reflect.ValueOf([]interface{}{1, 2}), reflect.ValueOf([]int{1}), "intersect", expect{true, false}},
544
+ {reflect.ValueOf([]int{1}), reflect.ValueOf([]interface{}{1, 2}), "intersect", expect{true, false}},
545
} {
546
result, err := ns.checkCondition(test.value, test.match, test.op)
547
if test.expect.isError {
0 commit comments