Skip to content

Commit

Permalink
fix: use deep equal in contains (#87)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Jan 17, 2024
1 parent 64da2e9 commit e430401
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ func TestSearch(t *testing.T) {
},
},
want: 42.0,
}, {
args: args{
expression: "contains(@, { foo: 'bar' })",
data: []interface{}{map[string]any{}, nil, map[string]any{"foo": "bar"}},
},
want: true,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/functions/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func jpfContains(arguments []interface{}) (interface{}, error) {
// Otherwise this is a generic contains for []interface{}
general := search.([]interface{})
for _, item := range general {
if item == el {
if reflect.DeepEqual(el, item) {
return true, nil
}
}
Expand Down

0 comments on commit e430401

Please sign in to comment.