Merge pull request #640 from travisturner/backport-executeclearrow

safe cast of bool in executeClearRow
This commit is contained in:
Travis Turner 2020-08-04 17:18:33 -05:00 committed by GitHub
commit 76dbedc082
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3074,11 +3074,18 @@ func (e *executor) executeClearRow(ctx context.Context, index string, c *pql.Cal
// Merge returned results at coordinating node.
reduceFn := func(ctx context.Context, prev, v interface{}) interface{} {
val := v.(bool)
if prev == nil {
val, ok := v.(bool)
if !ok {
return errors.Errorf("executeClearRow.reduceFn: val is non-bool (%+v)", v)
}
if prev == nil || val {
return val
}
return val || prev.(bool)
pval, ok := prev.(bool)
if !ok {
return errors.Errorf("executeClearRow.reduceFn: prev is non-bool (%+v)", prev)
}
return pval
}
result, err := e.mapReduce(ctx, index, shards, c, opt, mapFn, reduceFn)
@ -3166,7 +3173,7 @@ func (e *executor) executeSetRow(ctx context.Context, indexName string, c *pql.C
if !ok {
return errors.Errorf("executeSetRow.reduceFn: val is non-bool (%+v)", v)
}
if val {
if prev == nil || val {
return val
}