mirror of
https://github.com/pikami/cosmium.git
synced 2025-02-12 19:06:12 +00:00
Fix ARRAY_CONTAINS partial matches for nested objects
This commit is contained in:
parent
8657c48fc8
commit
3fee3bc816
@ -220,7 +220,7 @@ func (r rowContext) partialMatch(item interface{}, exprToSearch interface{}) boo
|
||||
}
|
||||
|
||||
for _, key := range exprValue.MapKeys() {
|
||||
if itemValue.MapIndex(key).Interface() != exprValue.MapIndex(key).Interface() {
|
||||
if !reflect.DeepEqual(itemValue.MapIndex(key).Interface(), exprValue.MapIndex(key).Interface()) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -59,10 +59,11 @@ func Test_Execute_ArrayFunctions(t *testing.T) {
|
||||
parsers.SelectStmt{
|
||||
Parameters: map[string]interface{}{
|
||||
"@categories": []interface{}{"coats", "jackets", "sweatshirts"},
|
||||
"@objectArray": []interface{}{map[string]interface{}{"category": "shirts", "color": "blue"}},
|
||||
"@fullMatchObject": map[string]interface{}{"category": "shirts", "color": "blue"},
|
||||
"@objectArray": []interface{}{map[string]interface{}{"category": "shirts", "color": "blue", "nestedObject": map[string]interface{}{"size": "M"}}},
|
||||
"@fullMatchObject": map[string]interface{}{"category": "shirts", "color": "blue", "nestedObject": map[string]interface{}{"size": "M"}},
|
||||
"@partialMatchObject": map[string]interface{}{"category": "shirts"},
|
||||
"@missingPartialMatchObject": map[string]interface{}{"category": "shorts", "color": "blue"},
|
||||
"@nestedPartialMatchObject": map[string]interface{}{"nestedObject": map[string]interface{}{"size": "M"}},
|
||||
},
|
||||
SelectItems: []parsers.SelectItem{
|
||||
{
|
||||
@ -133,17 +134,30 @@ func Test_Execute_ArrayFunctions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Alias: "ContainsNestedPartialMatchObject",
|
||||
Type: parsers.SelectItemTypeFunctionCall,
|
||||
Value: parsers.FunctionCall{
|
||||
Type: parsers.FunctionCallArrayContains,
|
||||
Arguments: []interface{}{
|
||||
testutils.SelectItem_Constant_Parameter("@objectArray"),
|
||||
testutils.SelectItem_Constant_Parameter("@nestedPartialMatchObject"),
|
||||
testutils.SelectItem_Constant_Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
[]memoryexecutor.RowType{map[string]interface{}{"id": "123"}},
|
||||
[]memoryexecutor.RowType{
|
||||
map[string]interface{}{
|
||||
"ContainsItem": true,
|
||||
"MissingItem": false,
|
||||
"ContainsFullMatchObject": true,
|
||||
"MissingFullMatchObject": false,
|
||||
"ContainsPartialMatchObject": true,
|
||||
"MissingPartialMatchObject": false,
|
||||
"ContainsItem": true,
|
||||
"MissingItem": false,
|
||||
"ContainsFullMatchObject": true,
|
||||
"MissingFullMatchObject": false,
|
||||
"ContainsPartialMatchObject": true,
|
||||
"MissingPartialMatchObject": false,
|
||||
"ContainsNestedPartialMatchObject": true,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user