Skip to content

Commit

Permalink
Filter the nulls when dataype is array of interface (#283)
Browse files Browse the repository at this point in the history
Co-authored-by: “jdattatr-tibco” <“[email protected]”>
  • Loading branch information
jdattatr-tibco and “jdattatr-tibco” authored Nov 1, 2023
1 parent 4702400 commit cd9a00e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions data/mapper/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,11 @@ func (obj *ObjectMapper) Eval(scope data.Scope) (value interface{}, err error) {
}
if filterNulls {
if val != nil {
arrValue[k] = val
// filter the nulls when dataype is []interface{}
if arr, ok := val.([]interface{}); ok && len(arr) == 0 {
} else {
arrValue[k] = val
}
}
} else {
arrValue[k] = val
Expand Down Expand Up @@ -513,7 +517,11 @@ func (f *foreachExpr) HandleFields(inputScope data.Scope) (interface{}, error) {
}
if filterNulls {
if val != nil {
vals[k] = val
// filter the nulls when dataype is []interface{}
if arr, ok := val.([]interface{}); ok && len(arr) == 0 {
} else {
vals[k] = val
}
}
} else {
vals[k] = val
Expand Down

0 comments on commit cd9a00e

Please sign in to comment.