Skip to content

Commit e430401

Browse files
authored
fix: use deep equal in contains (#87)
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
1 parent 64da2e9 commit e430401

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/api/api_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ func TestSearch(t *testing.T) {
139139
},
140140
},
141141
want: 42.0,
142+
}, {
143+
args: args{
144+
expression: "contains(@, { foo: 'bar' })",
145+
data: []interface{}{map[string]any{}, nil, map[string]any{"foo": "bar"}},
146+
},
147+
want: true,
142148
}}
143149
for _, tt := range tests {
144150
t.Run(tt.name, func(t *testing.T) {

pkg/functions/functions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func jpfContains(arguments []interface{}) (interface{}, error) {
141141
// Otherwise this is a generic contains for []interface{}
142142
general := search.([]interface{})
143143
for _, item := range general {
144-
if item == el {
144+
if reflect.DeepEqual(el, item) {
145145
return true, nil
146146
}
147147
}

0 commit comments

Comments
 (0)