Don’t fetch right side of AND / OR statements if not necessary

This commit is contained in:
Tobie Morgan Hitchcock 2018-04-20 00:17:13 +01:00
parent c4f8448345
commit 83edea8a66

View file

@ -233,6 +233,17 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
return nil, err
}
switch val.Op {
case sql.OR:
if calcAsBool(l) {
return true, nil
}
case sql.AND:
if !calcAsBool(l) {
return false, nil
}
}
r, err := e.fetch(ctx, val.RHS, doc)
if err != nil {
return nil, err